You are on page 1of 3

1 Marks: 1 If the following declarations and initializations are made, which expression wil l evaluate to true?

char c = 'B'; int i=3, j = 3, k = 3; double x = 0.0 , y = 2.3 ; Choose one answer. a. i>1 && j<1 && k>1 b. i>j && j-2<2 || j>3 c. y>1 || i<1 && j<3 d. !(4>j) && j>5 2 Marks: 1 '#define MAX_NUM 15' What is MAX_NUM? Choose one answer. a. MAX_NUM is a linker constant. b. MAX_NUM is an integer variable. c. MAX_NUM is a preprocessor macro. d. MAX_NUM is a precompiler constant. 3 Marks: 1 Which one of the following is NOT a valid C identifier? Choose one answer. a. __2 b. 1__ c. S__ d. __s 4 Marks: 1 Which one of the following is NOT a valid identifier name? Choose one answer. a. big_num b. _ident c. g42277 d. auto 5 Marks: 1 char x; /* assume x is 8 bits in size */ What is the maximum number that can be printed using printf("%d", x ), assuming that x is as shown above? Choose one answer. a. 255 b. Cannot print x using %d because x is a char c. 127 d. 128 6 Marks: 1

Which is the correct output when the following block of code is executed? int num1 = 30, num2 = 5; printf("%d, %d, %d, %d, %d", num1, num2, num1/num2, num1%num2, num2/num1); Choose one answer. a. 30, 5, 6, 0, 0.167 b. 30, 5, 6, 0, 0 c. 30, 5, 0.167, 0, 6 d. 30, 5, 6, 6, 0 7 Marks: 1 Identify the correct statement Choose one answer. a. A C program always has inputs and outputs b. Syntax errors and violation of language rules are checked at the compiling st age c. The syntax and coding style of C is not well structured. d. Programs written in languages like Visual Basic and Perl must be compiled bef ore executing 8 Marks: 1 Select the correct statement. Choose one answer. a. In a 'for' loop expression, the starting value of the control variable must b e less than its ending value. b. The 'do..while' statement first executes the loop control expression and then evaluates the loop body. c. A program stops its execution when a break statement is encounterd. d. A "switch" statement can always be replaced by a series of if..else statement s. 9 Marks: 1 How does variable definition differ from variable declaration? Choose one answer. a. Variable definition must precede variable declaration. b. Variables may be defined many times, but may be declared only once. c. Declaration allocates storage for a variable, but definition only informs the compiler as to the variable's type. d. Definition allocates storage for a variable, but declaration only informs the compiler as to the variable's type. 10 Marks: 1 The following program does not compile. Identify the line(s) that contain error( s). 1. include <stdio.h> 2. int main() 3. { 4. int i=0,j=5; 5. for(i=0;;i++) //outer loop 6. {

7. for(j=0;j<25;j++) // inner loop 8. { 9. printf("%i\n",j); 10. } // end of inner loop 11. 12. if (i => 11) 13. break 14. 15. printf(" "); 16. } //end of outer loop 17. return 0; 18. } Choose one answer. a. 5, 9 and 13 b. 1, 5 and 12 c. 1, 12 and 13 d. 1, 5 and 9 Time Remaining You are logged in as (Logout)

You might also like