Docsity

Exam 1 Solved - Structured Programming in C | CSCE 206, Exams of Computer Science

Toggle sidebar
bg1
True/False Questions
1. ABCD in hex is 1010101111001101 in binary. T
2. The header file contains machine code of functions that have already been compiled. F
3. Compiler MUST have the functional prototype of the invoked function to perform its job. T
4. If error occurs during performing fscanf, then fscanf returns EOF. T
5. When designing a program, one could start with smallest parts and then proceed to larger
parts. This type of process is known as Top โ€“ down Modular design. F
6. After preprocessing directive #define PI xyz is executed, statement printf("PI =
%f\n", PI); becomes printf("xyz = %f\n", xyz); F
7. Distributed computing is a technique of shared processing over networks. T
8. For the purpose of transferring bits, a machine's CPU and hard disks are connected by a
bus. F
9. Linker creates object code and stores it on disk. F
10. โ€˜?โ€™ and โ€œ?โ€ are different. But both of them can be assigned to a char variable. F
11. An assembler translates machine code into assembly language instructions. F
12. White space characters are considered tokens by the C compiler. F
13. 12345.0 and 12345.0f are constants of different types. T
14. int x = 4, z = 3, y;
y = 2 * ++x + z++;
Above will assign the value 13 to y. T
15. The semantics of a programming language can cause syntax errors. F
Multiple Choice Questions
16. What would be the output of the following code fragment? C
int c = 12345, d = 10;
printf(โ€œ%dโ€, d%c);
A. %d
B. 30
C. 10
D. 3
E. None of the above
17. After the following piece of code what would A be? E
int a = 4, b = 3,c = 2, d = 1;
a += b *= c += d;
A. 15
B. 14
C. 10
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Exam 1 Solved - Structured Programming in C | CSCE 206 and more Exams Computer Science in PDF only on Docsity!

True/False Questions

  1. ABCD in hex is 1010101111001101 in binary. T
  2. The header file contains machine code of functions that have already been compiled. F
  3. Compiler MUST have the functional prototype of the invoked function to perform its job. T
  4. If error occurs during performing fscanf, then fscanf returns EOF. T
  5. When designing a program, one could start with smallest parts and then proceed to larger parts. This type of process is known as Top โ€“ down Modular design. F
  6. After preprocessing directive #define PI xyz is executed, statement printf("PI = %f\n", PI); becomes printf("xyz = %f\n", xyz); F
  7. Distributed computing is a technique of shared processing over networks. T
  8. For the purpose of transferring bits, a machine's CPU and hard disks are connected by a bus. F
  9. Linker creates object code and stores it on disk. F
  10. โ€˜?โ€™ and โ€œ?โ€ are different. But both of them can be assigned to a char variable. F
  11. An assembler translates machine code into assembly language instructions. F
  12. White space characters are considered tokens by the C compiler. F
  13. 12345.0 and 12345.0f are constants of different types. T
  14. int x = 4, z = 3, y; y = 2 * ++x + z++; Above will assign the value 13 to y. T
  15. The semantics of a programming language can cause syntax errors. F Multiple Choice Questions
  16. What would be the output of the following code fragment? C int c = 12345, d = 10; printf(โ€œ%dโ€, d%c); A. %d B. 30 C. 10 D. 3 E. None of the above
  17. After the following piece of code what would A be? E int a = 4, b = 3,c = 2, d = 1; a += b *= c += d; A. 15 B. 14 C. 10

D. 7

E. 13

  1. The following are relational operators except: A A. ?= B. <= C. >= D. == E. !=
  2. Which of the following is the correct order of the Software Life Cycle?: B A. Design, Testing, Implementation, Analysis, Maintenance B. Analysis, Design, Implementation, Testing, Maintenance C. Analysis, Design, Testing, Maintenance, Implementation D. Design, Analysis, Implementation, Maintenance, Testing E. Analysis, Testing, Design, Implementation, Maintenance
  3. Which of the following is an example of a Secondary Storage Medium? (choose the most correct answer) E A. Tape drives B. Floppy disk drives C. zip disk drives D. CD-ROM drives E. All above
  4. We need a programming language in order to: (choose the most correct answer) D A. Tell the computer precisely what to do

D. To perform arithmetic computations and logical operations E. To handle data transmission between CPU and memory

  1. Which of the following line is NOT correct D int main(void) { char str[80]; // Line A printf("Enter a string: "); // Line B scanf("%s", str); // Line C printf("Here's your string: %s", str[0~79]); // Line D return 0; // Line E } A. Line A B. Line B C. Line C D. Line D E. Line E
  2. What will be the console output of the below statement? C printf(โ€œhello, \n programming \t worldโ€); A. hello, programming world B. hello, programming C. hello, programming world D. hello programming world E. none of above
  3. Which of the following is not a feature of C language? E A. Small B. Protable C. Terse

D. Modular E. Template programming

  1. What are physical devices that form the computer itself? D A. Device B. Main Frame C. Machine D. Hardware E. Space parts
  2. What does GUI stand for? E A. Grand Unsigned Integer B. Graphic Utility Invoker C. Graphic User Inaccuracy D. Great Ultimate Integer E. Graphic User Interface
  3. A program that controls the processing of the machine is a: B A. Translator B. Operating system C. Word Processor D. Machine Processor E. None of the above
  4. What is 10110111 (BINARY) in decimal format? E A. 238 B. 127 C. 72 D. 27

C. a += a += ++2; D. c = -(2+a); E. b -- - --c;

  1. scanf() must have _____ as its arguments. A A. addresses B. variable names C. functions D. integers E. doubles
  2. Choose the right output for the following code segment E int a= 3, b = 9, c = 4; a *= c % b++; printf("%d\n", a++); A. 45 B. 56 C. 57 D. 23 E. 12
  3. Find the correct output for the following code segment B int a, b, c = 1; a = c++; b = ++c; printf("%d %d %d", a, b, c); A. 0 1 2 B. 1 3 3 C. 1 2 2 D. 0 2 2 E. 1 1 2
  4. Find the correct output of the following program B

#include <stdio.h> int main(void) { int a = 0, b = 1; b = ( a != 1)+ (b == 0); printf("%d\n", ((a > b)? a : b)); return 0; } A. 0 B. 1 C. 2 D. 3 E. None of above

  1. What would be the output of the following code fragment? (โ€œ_โ€ in answers represents white space) D printf ("%7.2f%s%5s", 1.23, "x", "y"); A. _ _ _ 1.23x _ _ y B. 12.3xy C. xy _ _ _ _1. D. _ _ 1.23x _ _ _ y E. None of the above
  2. Which of the following is correct in syntax? D A. int a = 3, int b; B. printf "hello, world!"; C. scanf(โ€œ%dโ€, โ€œ%dโ€, &a, &b); D. scanf(โ€œ%d%dโ€, &a, &b); E. printf("First num = %d, 2nd num = %d");
  3. Which of the following is not a valid identifier: B A. a

B. -=

C. &&

D. ?:

E. %=

  1. Which one is true about Pseudocode (choose the most correct answer) E A. cannot be compiled and executed by a computer B. uses programming language structures such as if/else or while. C. is the steps of the algorithm written in natural language in a shorthand form which represents the flow of control through the algorithm. D. does not have a language-specific syntax E. all of the above.
  2. We know that lexical analysis is applied to C source code before code generation. The preprocessor in operating system is responsible for the lexical analysis. Thus the preprocessor strips out all of the following from the C code EXCEPT D A. tabs B. comments C. blanks D. variable declarations E. None of the above
  3. The best definition of an algorithm is B A. A set of mathematical equations. B. A process of translating a problem's solution into instructions that a computer can process. C. A program that run on a computer. D. A source code. E. A set of mathematical equations. A step-by-step procedure that solves a problem or accomplishes a desired task.