You are on page 1of 10

Question Paper for Technical Test in C Each question carries one mark each. 1.

What is the output of the following C program ? main( ) { extern int fun(float); int a; a = fun( 3.14 ); printf (%d, a); } int fun (aa) { return ( (int) aa); } a) 3.14 b) 3.0

c) 0

d) Error

2) What is the output of the following C program ? main ( ) { int a[5] = {2, 3}; printf(\n%d%d%d, a[2], a[3], a[4]); } a) Garbage values b) 2 3 3 c) 3 2 2 d) 0 0 0 3) What is the output of the following C program ? main ( ) { struct emp { char name[20]; int age; float sal; }; struct emp e = {tiger}; printf(\n%d%f, e.age, e.sal); } a) Error b) Garbage Value c) 0 0.000000 d) 1 0.000000

4) In the following C program find out the error if any ? main ( ) { int i = 1; for ( ; ; ) { printf(\n%d, i++); if (i > 10) break ; } a) b) c) d) } The condition in the for loop is a must. The two semicolons should be dropped. The for loop should be replaced by a while loop. No Error.

5) In the following C program find out the error if any ? main ( ) { int i = 1; while ( ) { printf(%d, i++); if (i > 10) break ; } } a) b) c) d) The condition in the while loop is a must. There should be at least semicolon in the while ( ). The while loop should be replaced by a for loop. No Error.

6) What is the o/p of the following C program ? main ( ) { int x = 10, y =10, z = 5, i; i = x < y < z; printf (\n%d, i); } a) 1 b) 0 c) Error d) 5

7) Consider the following C statement. What is the order in which the functions are called? a = f1(23, 14) f2(12/4) + f3 ( ); a) f1, f2, f3 c) order may vary from compiler to compiler 8) What is the o/p of the following C program ? main ( ) { float a = 0.7; if (a < 0.7) printf (C); else printf(C++); } a) C b) C++ c) Error d) None of the above. b) f3, f2, f1 d) None of the above

8) What is the o/p of the following C program ? main ( ) { printf (%f, sqrt(36.0)); } a) 6.0 b) 6 c) 6.000000 d) Some absurd result.

9) What is the o/p of the following C program ? main ( ) { printf (%d%d%d, sizeof(3.14f), sizeof(3.14), sizeof(3.14I)); } a) 4 4 4 c) 4 8 10 b) 4 garbage value d) Error.

10) If the binary equivalent of 5.375 in normalized form is 0100 0000 1010 1100 0000 0000 0000, 0000 what is the o/p of the following C program ? main ( ) { float a = 5.375; char *p; int i; p (char*)&a; for (i = 0 ; i <=3 ; i++) printf(%02x, (unsigned char) p[i];); } a) 40 AC 00 00 b) 00 CA 00 40 c) 00 00 AC 40 d) 00 00 CA 04.

11) What error would the following function given on compilation ? f (int a, int b ) { int a; a = 20; return a; } a) b) c) d) Missing parenthesis is return statement The function should be defined as int f (int a int b) Redeclaration of a None of the above.

12) How many times the following C program would print Jamboree? main ( ) { printf (\nJamboree); main( ); } a) Infinite number of times b) 32767 times c) 65535 times d) Till the stack doesnt overflow 13) What is the o/p of the following C program ? main ( ) { printf (5+ Fascimile); } a) Error b) Unequal c) mile d) None of the above

14) The following program(myprog) is run from the command line as myprog 1 2 3 what would be the output ? main(int argc, char*argv[] ) { int i, j = 0 ; for (i = 0 i < argc ; i++) j = j + atoi(argv[i]); printf(%d, j); } a) 123 b) 6 c) Error d) 123

15) The following C program(myprog) is run from the command line as myprog friday tuesday sunday what would be the output ? main(int argc, char*argv[] ) { printf (%c, **++argv); } a) m b) f c) myprog d) friday

15) The following C program(myprog) is run from the command line as myprog friday tuesday sunday what would be the output ? main(int sizeofargv, char*argv[] ) { while (sizeofargv); printf (%s, argv[--sizeofargv]); } a) b) c) d) myprog friday tuesday sunday myprog friday tuesday. sunday tuesday friday myprog sunday tuesday friday

16) What is the o/p of the following C program ? main( ) { int i = 32, j = 0 x 20, k, l, m; k = i | j; l=i&j; m=k l; printf(%d%d%d%d%d, i, j, k, l, m); } a) 32 32 32 32 0 b) 0 0 0 0 0 c) 0 32 32 32 32 d) 32 32 32 32 32 17) What is the o/p of the following C program ? main( ) { unsigned int m = 32 ; printf(%x, m); } a) ffff b) 0000 c) ffdf d) ddfd 18) What is the o/p of the following C program ? main( ) { const int x = 5; int *ptrx ; ptrx = &x; *ptrx = 10; printf(%d, x); } a) 5 b)10 c) Error

d) Garbage Value

19) The value of an automatic variable that is declared but not initialized will be a) 0 b) 1 c) Garbage d) None of the above. 20) Which of the following operators in C programming language takes only integer operands? a) + b) * c) / d) % 21) What is the result of execution of the following C statement. int i = 5; do {putchar (i + 100); printf(%d, i--); } while (i) ; a) 15h4g3f2el c) Error message b) 14h3g2fle0 d) None of them.

22) Consider the following statements in C. for (i = 3 ; i< 15 ; i+ = 3) { printf (%d, i); ++ i ; } The execution of these statements results in printing of a) 3 6 9 12 b) 3 6 9 12 15 c) 3 7 11 23) Which of the following statements are syntactically correct ? a) for ( ) ; b) for ( ; ); c) for ( , ) ;

d) 3 7 11 15 d) for (; ;);

24) It is necessary to declare the type of a function in the calling program if a) the function returns an integer. b) the function returns a non-integer value. c) the function is not defined in the same file. d) none of the above. 25) A static variable a) cannot be initialized b) is initialized once at the commencement of the execution and cannot be changed at runtime. c) retains its value throughout the life of the program. d) is same as an automatic variable but is placed at the head of a program. 26) Consider the following program fragment main( ) { int a, b, c; b = 2; a = 2 * (b++); c = 2 * (++b); } which of the following is correct ? a) a = 4, c = 6 b) a = 3, c = 8 27) What is the final value of sum ? main( ) { int sum = 1; for ( ; sum <=9 ; ) printf(%d\n, ++sum); } a) 10 b) 9 c) 11

c) b = 3, c = 6

d) a = 4, c = 8

d) None of the above

28) What is the o/p of the following program ? main( ) { int x, y, z; x = 2; y = 1; z = 1; if (x > y + z) printf (Hello!\n); else printf (Hey!\n); } a) Hi! b) Hello! c) Hey! 29) main( ) { float balance, loan; balance = 1000.0; loan = balance / 10; if ((balance > 500) || (loan < 500)) printf (Good Account\n); if ((balance < 500) || (loan < 500)) printf (Caution\n); } What is the o/p of the above program ? a) Good Account b) Caution c) Good Account Caution d) None of the above

d) None of the above

30) The following lines if included in the program will cause one of the following errors ? Indicate the correct one ? { double c ; scanf (%c, c); } a) runtime error b) compilation error c) typedef error d) no error 31) What is the following program doing ? main( ) { int digit = 0; do printf (%d\n, digit++); while (digit <= 9); } a) adding 9 integers b) adding integers from 1 to 9 c) display any 9 integers d) display integers from 1 to 9

32) The declarations typedef float height [100] ; height men, women ; a) b) c) d) define men & women as 100 elements floating point arrays. define men & women as 100 elements floating point variables. define height, men & women as 100 elements floating point arrays. are illegal.

33) If the address of the 8th element in a link list of integers is 1022, then the address of 9th elements is a) 1024 b) 1026 c) 1023 d) None of these 34) What will be the value return by the following function when it is called with 11? recur (int num) { if ((num / 2) ! = 0) return (recur(num/2)) *10 + num%2); else return 1 ; } a) b) c) d) Function does not return any value ; because it gets into an infinite loop 11 1011 none of the above

35) Consider the following set of statements : float x, y; x = 7; y = 10; x* = y* = y + 28.5; After the execution of the above set of statements, the value of x will be a) 70 b) 2695 c) 2995 d) none of the above 36) A structure brings together a group of a) items of the same data type c) integers with user defined names b) related data items and variables d) none of the above

37) When an array name is passed to a function, the function a) accesses exactly the same array with the same name as the calling program b) accesses a copy of the array passed by the program c) refers to the array using the same name as that used by the calling program d) none of the above 38) A pointer is a) address of a variable b) an indication of the variables to be accessed next c) a variable for storing address d) none of the above

You might also like