You are on page 1of 14

Answers

C Aptitude Questions
01) Which header file should you include if you are to develop a function that can variable number of arguments? a) Vararg.h c) stdio.h 02) In a C program, constant is defined a) before main. c) anywhere, but starting on a new line. 03) printf(%d.printf(tim*)); a) result in a syntax error. c) output garbage. 04) The rule for implict type conversion in C is a) int<unsigned<float<double. c) int<unsigned<double<float. 05) b) unsigned<int<float<double. d) unsigned<int<double<float. b) outputs tim3. d) prints tim and terminates abruptly. b) after main. d) none of the above. b) stdlib.h d) stdarg.h accept

Which of the following statements is correct? a) C provides no input-output features. b) b) C provides no file access features. c) provides no features to manipulate composite objects. d) all of the above.

06)

Integer division in a C program results in a)truncation. c) overflow. b) rounding. d) none of the above.

07)

For C programming language,which of the following statements is (are) true ? a) Constant expression are evaluated at compile time. b) String constants can be concatenated at compile time. c) Size of the array should be known at compile time. d) all of the above.

Answers
08) In a C expression involving || operator, evaluation a) will be stopped if one of its components evaluates to false. b) will be stopped if one of its components evaluates to true. c) takes place from right to left. d) takes place from left to right. 09) Which of the following statements is (are) correct ? a) enum variables can be assigned new values. b) enum variables can be compared. c) enumeration feature does not increase the power of C. d) all of the above. 10) Which of the following comments regarding the reading of a string,using scanf (with option) and gets is true ? a) Both can be used interchangeably. b) scanf is delimited by end of line, while gets is not c) scanf is delimited by blank , while gets is not. d) none of the above. 11) Which of the following comments about the ++ operator is (are) correct? a) b) c) d) e) 12) It is unary operator. The operand can come before or after the operator. It can not be applied to an expression. It associates from the right. all the above.

When a variable of data type double is converted into float then a) b) c) d) rounding takes place. truncation takes place. the lower order bits are dropped. none of the above.

13)

Which of the following C statements is syntactically correct? a) for(); c) for(,); b) for(;); d) for(;;);

14)

Consider for loop in a C program.If the condition is missing

Answers
a) it is assumed to be present and taken to be false. b) it is assumed to be present and taken to be true. c) it results in a syntax error. d) execution will be terminated. Which of the following statements about for loop are correct? a) b) c) d) 16) index value is retained outside the loop. index value can be changed from within the loop. Goto can be used to jump,out of the loop. All of the above.

15)

Arrays can be initialized provided they are a) Automatic. c) Static. b)External. d)Both (2) and (3) above.

17)|

Arrays are passed as arguments to sa function by a) value. c) both (1) and (2) above. b) Reference. d) none of the above.

18)

It is necessary to declare the type of a function in the calling program if a) b) c) d) the function returns an integer. the function returns a non-integer value. the function is not defined in the same file. none of the above.

19)

The declaration void function 1(int)indicates the function 1 is a function which a) b) c) d) has no arguments. returns nothing. both(1) and (2) above. None of the above.

20)

Recursive functions are executed in a a) b) c) d) Last in first out order. First in first out order. Parallel fashion. all of the above.

21)

When a function is recursively called,all automatic variables a) are initialized during each execution. b) are retained from the last execution.

Answers
c) are maintained in a stack. d) none of the above. 22) A static variable a) cannot be initialized. b) is initialized once at the commencement of execution and cannot be changed at run time. c) retains its value throughout the file of the program. d) is same as an automatic variable but is placed at the head of a program. 23) An external variable a) b) c) d) 24) is globally accessible by all functions has a declaration extern associated with it when declared within a function. will be initialized to 0 if not initialized. all of the above.

A switch statement is used to a) switch between functions in a program. b) switch from one variable to another variable. c) to choose from multiple possibilities which may arise due to different values of a single variable. d) to use switching variable.

25)

The statement #include<math.h>is written at the top of a program to indicate a) the beginning of the program. b) the program does heavy mathematical calculations c) that certainly information about mathematical library functions are to be included at the beginning of the program. d) none of the above.

26)

What is the output of the following C program? main( ) { extern int I; i=20; printf(%d,sizeof(i)); } a) b) c) d) 2 4 would vary from compiler to compiler. Error, i underdefined.

Answers
27) What is the output of the following C program? main( ) { extern int a; printf(\n%d,a); } int a=20; a) b) c) d) 0 20 Error. Garbage value.

28)

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); float aa; { return ((int)aa); } a) b) c) d) 3.14 3.0 0 Error.

29)

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

Answers
c) 3 2 2 d) 0 0 0

30)

What is the output of the following C program? main( ) { Struct emp { char name[20]; int age; flat sal; }; struct emp e={Tiger}; printf(\n%d%d%f,e.age,e.sal); a) b) c) d) Error. Garbage value 00.0000000 10.000000

31)

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

32)

In the following C program,find out the error in the while loop,if any ? main( ) { int i=1;

Answers
While( ) { printf(%d,i++); if(i>10) break; } } a) b) c) d) 33) the condition in the while loop is a must. there should be atleast a semicolon in the while( ). the while loop should be replaced by for loop. No error.

What is the output of the following C program? main( ) { int i=2; printf(\n%d%d,++i,++i); } a) b) c) d) 3 4 4 3 4 4 output may vary from compiler to compiler.

34)

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

35)

Consider the following C statement.what is the order in which functions are called? A=f1(23,14)*f2(12/4)+f3(); a) f1,f2,f3 b) f3,f2,f1 c) the order may vary from compiler to compiler.

Answers
d) None of the above. 36) In the following Ccode in which order the functions would be called? a= (f1(23,14)*12(12/4))+f3(); a) b) c) d) f1,f2,f3 f3,f2,f1 The order may vary from compiler to compiler. None of the above.

37)

What is the output of the following C program? main( ) { float a=0.7; if(a<0.7) printf(C); else Printf(C++); } a) b) c) d) C C++ Error. None of the above.

38)

What is the output of the following C program? main( ) { float a=0.7; if(a<0.7f) printf(C); else printf(C++); } a) C b) Error b)C++ d)None of the above.

39)

What is the output of the following C program? main( ) {

Answers
printf(%f,sqrt(36.0)); } a) b) c) d) 40) 6.0 6 6.000000 Some absurd value.

We want to round off x,a float, to an int value.What is the correct way to do so? a) b) c) d) y=(int)(x+0.5) y=int(x+0.5) y=(int) x+0.5; y=(int)((int)x+0.5).

41)

What error are you likely to get when you run the following program? main( ) { struct emp { char name[20]; float sal; } struct emp-e[10]; int I; for(i=0;<=9;i++) scanf(%s%f,e[i].name,&e[i].sal); a) b) c) d) Suspicious pointer conversion Floating pint formats not linked Cannot use scanf( )for structures. Strings cannot be nested inside structures.

42)

By default any real number in C is treated as a) b) c) d) a float a double a long double Depends upon the memory model that you are using.

43)

What is the output of the following C program? main( ) {

Answers
pritnf(%d%d%d,sizeof(3.14f),sizeof(3.14),sizeof(3.14I)); } a) b) c) d) 44) 444 4 Garbage value 4 8 10 Error

If the binary equivalent of 5.375 in normalized form is 0100 0000 1010 1100 0000 0000 0000,0000 what is the output of the following 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) b) c) d) 40 AC 00 00 00 CA 00 40 00 00 Ac 40 00 00 CA 04

45)

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 parantheses is return statement The function should be defined as int f(int a, int b) Redeclaration of a None of the above.

46)

How many times the following C program would print Jamboree ? main( ) { printf(\nJamboree);

Answers
main(); } a) b) c) d) 47) Infinite number of times. 32767 times. 65535 times. Till the stack doesn`t overflow.

What is the output of the following C program? main( ) { printf(5+Fascimile); } a) b) c) d) Error Fascimile mile None of the above

48)

What is the output of the following C program? main( ) { char str1[]=Hello char str2[]=Hello if(str1== str2) printf(\nEqual); else pirnt(\nUnequal); }

a) b) c) d) 49)

Equal Unequal error None of the above.

What is the output of the following C program? main( ) { printf(%c,abcdefgh[4]);

Answers
} a) b) c) d) 50) Error d e abcdefgh

What is the output of the following C program? main( ) { char str[7]=Strings; printf(%s,str); } a) b) c) d) Error Strings Cannot predict None of the above.

Back

ANSWERS
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. d c b a d a d d d c 5 a d b 5 d b b b a a b d c c 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. d b d d c d a d a c c a b d a b b c c c d c d c c

50.

Back

You might also like