Top C-Programming MCQ with Answers

1. What is the output of the following problem ?

#include
int main()
{
int i=4;
if(i=0)
printf("statement 1");
else
printf("statement 2");
return 0;
}

A. statement 1
B. statement 2
C. Compilation Error
D. No Output

Answer:B


2. #include
int main() {
int i,j;
j = 10;
i = j++ - j++;
printf("%d %d", i,j);
return 0;
}

A. 0 12
B. 12 12
C. 0 0
D. 12 0

Answer:A

3. int main()
{
int const * p=5;
printf("%d",++(*p));
return 0;
}

A. Compiler error
B. 5
C. 6
D. None of these
Answer:A


4. #include
#define max
int main(){
printf("%d",max);
return 0;
}

A. 0
B. null
C. Garbage
D. Compilation error
Answer:D

5. What is the output of the following 'C' program?

#include
void main() {
int x = 10,y = 10, z = 5, i;
i = x;
printf("%d",i==x);
}

A. 1
B. Error
C. 0
D. 5
Answer:A

6. What does the following 'C' program do ?

#include
void main()
{
unsigned int num;
int i;
scanf("%u", &num);
for (i = 0; i < 16; i++)
printf("%d", (num << i & 1 << 15)? 1:0);
}

A. It prints all even bits form num
B. It prints binary equivalent of num
C. It prints all odd bits from num
D. None of these

Answer:B

7. What is the output of the following program ?

include
int main()
{
int x,y=2,z,a;
x = (y*=2) + (z=a=y);
printf ("%d", x);
return 0;
}

A. 7
B. 8
C. 6
D. syntactically wrong
Answer:B

#include
void main()
{
int x,y=2,z,a;
if(x=y%2)
z=2;
a=2;
printf("%d %d",z,x);
}

A. 1..0
B. 2..0
C. 2..1
D. Garbage-value 0
Answer:D

9. What is the output of the following 'C' program ?

#include
void fun(void)
{
static int s = 0;
s++;
if(s == 10)
return;
fun();
printf("%d ", s);
}

int main(void)
{
fun();
}

A. 9 times 10
B. 10 times 10
C. Compilation Error
D. None of these
Answer:A

10. What is the output of the following 'C' program ?

void main(){
char c=125;
c=c+10;
printf("%d",c);
}

A. 135
B. INF
C. -121
D. Compilation Error
Answer:C

11. What is the correct way to round off x, a float, to an int value?

A. y = (int)(x + 0.5);
B. y = int(x + 0.5);
C. y = (int)x+ 0.5;
D. y = (int)((int)x + 0.5);
Answer:A

12. In C programming language the below statement means.

A. x = x-y + 1
B. x = -x -y - 1
C. x = -x + y + 1
D. x = x -y -1
D. y = (int)((int)x + 0.5);
Answer:D

13. What is the output of the following program ?
void main()
{
printf("%d",10?0?5:1:12);
}

A. 10
B. 0
C. 12
D. 1
Answer:D

14. What is the output of the following program ?

#include
void main()
{
int i= 5;
if (i == 5)
return 0;
else
printf("i is not five");
printf("over");
}

A. a syntax error
B. an execution error
C. printing of overan error message
D. execution termination, without printing anything
Answer:D

15. What is the output of the following "c" program ?

#include
void main()
{
int i = 107, x = 5;
printf ((x > 7)? "%d" : "%c:, i)
}

A. an execution error
B. a syntex error
C. printing of k
D. none of these
Answer:C

16. What is the output of the following C Program?

#include
void main()
{
int a=4, b = 6;
printf ("%d", a==b);
}

A. outputs an error message
B. 0
C. 1
D. none of these
Answer:B

17. The rule for implicit type conversion in 'C' is

A. int < unsigned < float < double
B. unsigned < int < float < double
C. int < unsigned < double < float
D. unsigned < int < double < float
Answer:A

18. Integer division in a 'C' program results in

A. truncation
B. rounding
C. overflow
D. none of these
Answer:A

19. The value of an automatic variable that is declared but not initialized will be

A. 0
B. '-1
C. garbage
D. none of these
Answer:C

20. Which of the following operators in 'C' does not associate from the left?

A. +
B. ,
C. =
D. %
Answer:C
21. Which of the following operators in 'C' programming language takes only integer operands?

A. +
B. *
C. /
D. %
Answer:C

22. Which of the following option is correct for the below program?

#include
void main()
{
int a,b,c;
b=2;
a= 2*(b++);
c = 2*(++b);
}

A. a=4,c=6
B. a=3,c=8
C. b=3, c=6
D. a=4, c=8
Answer:D

23. What is the output of the program?

#include
int main () {
int ( *Commprintf) (const char*, ... ) = printf;
Commprintf ( "Hello World");
return 0;
}

A. No output
B. Undefined symbol Commprintf
C. Compile Error: Prototype mismatch
D. Hello World
Answer:D
24. What is the problem in the following declarations?

int func(int);
double func(int);
int func(float);

A. A function with same name connot have different signatures.
B. A function with same name cannot have different return types.
C. A function with same name cannot have different number of parameters
D. All of the mentioned.
Answer:D

25. What is the output of the following code?

include
void main()
{
int a=0, b=0;
a = (b =75)+9;
printf("\n%d, %d ",a,b);
}

A. 75, 9
B. 75, 84
C. 84, 75
D. None of these Options
D. Hello World
Answer:C

26. Assignment operator targets to

A. L-value
B. H-value
C. None of the above
D. Both (a) and (b)

Answer:A

27. What will be output of the following "c" code?

#include
void main()
{
100;
printf("%d",100);
}

A. Compilation Error
B. 100
C. 1
D. None of these
Answer:B

28.  What will be output of the following "c" code?

#include
void main()
{
int i=10;
i=!i>14;
printf("%d", i);
}

A. 0
B. 10
C. 1
D. Compilation Error

Answer:A

29. What will be output of the following "c" code?

#include
void main ( )
{
int i;
for( i=0; i<10; i++,printf("%d", i));
}

A. 2345678910
B. 123456789
C. Compilation Error
D. 12345678910
Answer:D

30. What will be output of the following "c" code?

#include
void main ( )
{
int a=500, b=100,c;
if( !(a>=400))
b=200;
c=200;
printf( "%d %d", b,c);
}

A. 200 100
B. 100 200
C. 200 200
D. Compilation Error
Answer:B

31. What will be output of the following "c" code?

#include
void main ( )
{
int i, m=2, n=3;
for( i=0;m+n=5; m++)
printf("%d %d", m,n);
}

A. Compilation Error
B. 2 3
C. 3 3
D. 2 3 3 3
Answer:A

32. What will be output of the following "c" code?

#include
void main ()
{
int x =400, y;
y = x*x+x;
printf ("% d", y);
}

A. 400
B. 320000
C. Compilation Error
D. 160400
Answer:D

33. What is the output of the following program?

void main()
{
int x,y, z;
x=2; y=1; z = 1;
if(x > y + z)
printf("Hello!\n");
else if (x < y+ z)
printf ("Hi!\n");
else
printf("Hey!\n");
}

A. Hi!
B. Hey!
C. Hello!
D. None of these
Answer:B

34. What will be output of the following "c" code?

#include
void main ( )
{
int i, m=2, n=3;
for( i=0;m+n=5; m++)
printf("%d %d", m,n);
}

A. Compilation Error
B. 2 3
C. 3 3
D. 2 3 3 3
Answer:A

35. What would be the output of the following C program ?

void main() {
int = 12345;
float x = 145.678;
printf ("%3d, %5d, %8d", i,i,i,);
}

A. 123 123 123
B. 123,451,234,512,346
C. 12345
D. 123
Answer:C

36. The declaration "unsigned u" indicates

A. u is an unsigned character
B. u is an unsigned integer
C. u is a character
D. None of these
Answer: B

37. A declaration "short int" is used for variables

A. Which have a short duratioin a program
B. Which have short names
C. which may require less storage than normal integers
D. None of these
Answer:C

38. In case of ordinary int variables

A. leftmost bit is reserved for sign
B. rightmost bit is reserved for sign
C. no bit is reserved for sign
D. None of these
Answer:A

39. Find the output for the following C program

#include
int main()
{
int x=2,y=6,z=6;
x=y==z;
printf("%d",x);
}

A. 3
B. 0
C. None of these
D. 1
Answer:D
40. Find the output for the following C program

void main
{
int x,j,k;
j=k=6;x=2;
x=j*k;
printf("%d", x);
}

A. 2
B. 36
C. 6
D. None of the above
Answer:B

41. In signed magnitude notation what is the minimum value that can be represented with 8 bits

A. -128
B. -255
C. -127
D. 0
Answer:A
42. #include
void main()
{
unsigned short a=-1;
unsigned char b=a;
printf("%d %d ",a,b);
}
What is output of the program?

A. 65535 -1
B. 65535 65535
C. 65535 255
D. -1 -1
Answer:C
43. What will be the result of the following program?

#include
int main()
{
static int i;
int j;
for(j=0;j<10;j++)
{
i= i+2;
i = i-j;
}
printf("%d",i);
return 0;
}

A. 25
B. -25
C. 20
D. -20
Answer:B

44. What will be output of following c program?

#include
long unsigned static const ddlg(){
static const long unsigned a=0101;
return a;
}
int main(){
long number;
number=ddlg();
printf("%X",number);
return 0;
}

A. 41
B. 43
C. Compilation error
D. None of the above
Answer:A
45. Which is the valid declaration?

A. #typedef struct { int i;}in;
B. typedef struct in {int i;};
C. #typedef struct int {int i;};
D. typedef struct {int i;} in;

Answer:D

46. printd (int n)
{
if (n < 0)
{
printf ("-");
n = -n;
}
if (n % 10)
printf ("%d", n);
else
printf ("%d", n/10);
printf ("%d", n);
}

If initially n = -24;

A. -24
B. 24
C. -2424
D. None of the above
Answer:C

47. What is the output of the following 'C' program ?

#include
int main()
{
int i = 10 ;
printf("%d\n", i/2 );

}

A. 10
B. 5
C. error
D. warning
Answer:B

48. What is the output of the following 'C' program ?

#include
int main()
{
char c = 255;
printf ("%d",c);
return 0;
}

A. illegal character assignment
B. prints -1
C. prints 2
D. prints 255
Answer:B

49. What will be output of the following "C" code?

#include
main()
{
100;
printf("%d",100);
}

A. Error
B. 100
C. Garbage value
D. 100100
Answer:B
50. Predict the output of following code:

void main()
{
float a=1.1;
double b=1.1;
if(a==b)
printf("equal");
else
printf("not equal");
}

A. ? equal
B. not equal
C. Error
D. equal not equal
Answer:B

51. Predict the output of following code:

#include
void main()
{
int sum;
char ch1='a';
char ch2='b';sum=ch1+ch2;
printf("%d",sum);
}

A. Error
B. 195
C. 201
D. "ab"

Answer:B

52. Predict the output of following code:

#include
void main()
{
int a=b=c=d=10;
printf("%d,%d,%d,%d",a,b,c,d);
}

A. Error
B. 10,10,10,10
C. GV,GV,GV,10
D. GV,GV,GV,GV

Answer:A

53. What will be output of the following "C" code?

main()
{
int i=-1;
-i;
printf("%d,%d",i,-i);
}

A. -1, 1
B. -1, -1
C. 1, 1
D. 0, 1

Answer:A

54. What could be the output for following "C" code?

main()
{
int a= - - 2;
printf("%d",a);
}

A. 2
B. -2
C. 1
D. Error
Answer:A

55. What is the output of this C code?

#include
int main()
{
short int i;
scanf("%hd", &i);
printf("%hd", i); return 0;
}

A. Compilation error
B. Undefined behavior
C. Whatever user types
D. None of these
Answer:C

56. fputs function is used to

A. Write characters to a file
B. Takes 2 parameters
C. Returns a character
D. Requires a file pointer
Answer:D

57. The function fprintf is used in a program

A. when too many printf calls have been already used in the program
B. in place of printf, since printf uses more memory
C. when the output is to be printed on to a file
D. when the type of the variables to be printed are not known apriori
Answer:C
58. What is the following C Program doing?

void main ()
{
char line [80];
gets (line);
puts (line);
}

A. prints horizontal straight lines on screens
B. prints 80 vertical lines on screen
C. reads in a line of 80 characters
D. reads and prints lines composed of characters
Answer:D

59. if i,j,k are integers, the scanf function to enter i,j,k such that i is decimal,j is octal and k is hexadecimal would be

A. scanf("%x %x %8x",i,j,k)
B. scanf("%d %o %x", i,j,k)
C. scanf("%d %o %x",&i, &j, &k)
D. scanf("%d %8d %16d", &i, &j, &k)
Answer:C

60. What would be the output of the following C program if input to the program is 'e'?

void main ()
{
char lower, upper;
lower = getchar();
upper= toupper (lower);
putchar (upper);
}

A. 53
B. e
C. E
D. Nothing
Answer:C

61. float x, y, z;
scanf ("%f %f", &x, &y);

If input stream contains "4.2 3 2.3 ..."
What will x and y contain after scanf?

A. 4.2, 3.0
B. 4.2, 2.3
C. 4.2 2.0
D. None of the above
Answer:A

62. What is the output of the following problem ?

#include
int main()
{
char *c;
c = "Hello";
printf("%s\n", c);
return 0;
}

A. Hello
B. H
C. ello
D. Compilation Error
Answer:A

63. What is the output of the following problem ?

#include
int main()
{
char *str = "12345";
printf("%c %c %c\n", *str, *(str++), *(str++));
return 0;
}

A. 3 2 1
B. 1 2 3
C. 3 4 5
D. Compilation Error
Answer:A
64. What is the output of the following problem ?

#include
int main()
{
int len=4;
char *st="12345678";
st = st + len;
printf("%c\n",*st);
return 0;
}

A. 5
B. 4
C. 12345678
D. Compilation Error
Answer:A
65. int main()
{
char string[]="Hello World";
display(string);
return 0;
}
void display(char *string)
{
printf("%s",string);
}

A. Hello World
B. Hello
C. World
D. None of these
Answer:D

66. #include
void main()
{
char a[]="12345\0";
int i=strlen(a);
printf("Value of i %d\n",++i);
}

A. Value of i 6
B. Value of i 5
C. Value of i 7
D. Compilation Error
Answer:A

67.
void main()
{
int i;
char a[]="\0";
if(printf("%s\n",a))
printf("Ok Done \n");
else
printf("Forget it\n");
}

A. Forget it
B. Ok Done
C. Compilation Error
D. None of these
Answer:B
68. What is the output of the following 'C' program ?


void main()
{
char str1[] = "Hello";
char str2[] = "Hello";
if (str1 == str2)
printf("\nequal");
else
printf("\nUnequal");
}

A. Equal
B. Error
C. Unequal
D. None of these
Answer:C
69. What is the output of the following C Program?

void main() {
int i, n;
char *x = "girl";
n = strlen(x);
*x = x[n];
for(i=0; i {
printf("%s\n",x);
x++;
}}

A. Segmentation fault
B. girl irl rl l
C. (blank space) irl rl l
D. Compilation Error
 Answer:A

70.
void main()
{
while (strcmp("some","some\0"))
printf("Strings are not equal\n");
}

A. No Output No Error
B. String are not equal
C. Compilation Error
D. None of these
Answer:A
71. #include
void main()
{
char str1[] = {'s','o','m','e'};
char str2[] = {'s','o','m','e','\0'};
while (strcmp(str1,str2))
printf("Strings are not equal\n");
}

A. No Output No Error
B. String are not equal
C. stack overflow
D. None of these
 Answer:C

72. What is the output of the following 'C' program ?


int main()
{
char arr[] = "Its very beautiful";
char *ptr = "Hello world";
char *str = "Sieze the day";
ptr = &arr[0];
printf("%s\n", ptr);
ptr = &str[0];
printf("%s\n", ptr);
}

A. Compilation Error
B. Its very beautiful Hello world
C. Its very beautiful Sieze the day
D. None of these
 Answer:B
73. What is the output of the following 'C' program ?


int main()
{
char arr[] = "Its very beautiful";
char *ptr = "Hello world";
char *str = "Sieze the day";
ptr = &arr[0];
printf("%s\n", ptr);
ptr = &str[0];
printf("%s\n", ptr);
}

A. Compilation Error
B. Its very beautiful Hello world
C. Its very beautiful Sieze the day
D. None of these
 Answer:B

74. Recursive function are executed in

A. Last in first out order
B. First in first out order
C. Parallel fashion
D. all of these
Answer:A
75. What is the output of the program?


void main ()
{
char str[][5] = {{'h','e','l','l'}, {'w','e','l','l'}};
printf("\n %s ", strncpy (*str, *(str + 1), 0));
}

A. ell
B. well
C. wel
D. hell
Answer:D

76. What is the output of the program?

void main () {
char str[][5] = {{'h','e','l','l'}, {'w','e','l','l'}};
char str1[15] = "All is ";
printf ("%s ", strcat(strchr(str1, 'l'), *(str+1)));
}

A. lwell
B. llwell
C. ll is well
D. l is well

Answer:C
77. Predict the output or error(s) for the following:

void main()
{
char string[]="Hello World";
display (string);
}
void display (char *string)
{
printf("%s",string);
}

A. Compiler Error : Type mismatch in redeclaration of function display
B. Hello World
C. Hello
D. segmentation fault

Answer:A

78. In a compiler there is 36 bit for a word and to store a character 8 bits are needed. IN this to store a character two words are appended .Then for storing a K characters string, How many words are needed.

A. 2k/9
B. (2k+8)/9
C. (k+8)/9
D. 2*(k+8)/9
Answer:A
79. What will be output of the following "c" code?

void main()
{
char s[]="main";
int i;
for(i=0; s[i]; i++)
printf("%c %c %c %c", s[i], *(s+i), *(i+s),i[s]);
}

A. main
B. Compilation Error
C. m m m ma a a ai i i in n n n
D. None of these
Answer:C

80. Predict the output or error(s) for the following:

main()
{
char string[]="HelloWorld";
display (string);
}
void display (char *string){
printf("%s",string);
}

A. Hello
B. HelloWorld
C. Syntax Error
D. Compiler Error
Answer:D

81. What will be the result of the following program?


int main(){
char p[]="String";
int x;
if(p=="String"){
printf("Pass 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
else{
printf("Fail 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
return 0;
}

A. Pass 1 Pass 2
B. Fail 1 Fail 2
C. Pass 1 Fail 2
D. Fail 1 Pass 2
Answer:D
82. What will be the result of the following program?

#include
#include
char *gxxx(){
static char xxx[1024];
return xxx;
}
int main(){
char *g="string";
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,"oldstring");
printf("The string is : %s",gxxx());
return 0;
}

A. The string is: string
B. The string is: Oldstring
C. Run time error/Core dump
D. Syntax error during compilation
Answer:B
83. What is the output of the following 'C' program ?

#include
int main()
{
char str1[]="Hello";
char str2[]="Hello";
if ( str1==str2 )
printf("True\n");
else
printf("False\n");
}

A. TRUE
B. FALSE
C. Error
D. Unpredictable
Answer:B
84. What is the output of the following 'C' program ?

#include
int main()
{
char a[] = "world";
printf("%d %d\n",strlen(a),sizeof(a));
return 0;
}

A. 5,5
B. 6,5
C. 5,6
D. 6,6
Answer:C
85. What is the output generated?

#include
int main()
{
char *s = "Hello";
printf("%s",(s+1));
return 0;
}

A. ello
B. Hello
C. Compilation Error
D. Segmentation fault
D. 6,6
Answer:A
86. What is the output of the following 'C' program ?


int main()
{
char *s = "Hello";
printf("%s",1(s));
}

A. Hello
B. ello
C. e
D. none of these

Answer:B

87. What is the output of the following 'C' program?

void main()
{
int i=3;

switch(i)
{
default:printf("zero");
case 1: printf("one");
break;
case 2:printf("two");
break;
case 3: printf("three");
break;
}
}

A. zero three
B. three
C. zero one
D. zero
Answer:B
88. What is the output of the following 'C' program?


main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;
case j: printf("BAD");
break;
}
}

A. Compiler error: case label does not reduce to an integer constant
B. GOOD
C. BAD
D. None of these
Answer:A
89. What is the output of the following 'C' program?


void main()
{
int i=10,j=20;
j=i,j?(i,j)?i:j:j;
printf("%d %d",i,j);
}

A. 10 10
B. 10 20
C. 20 10
D. Compilation Error
Answer:A
90. What is the output of the following 'C' program?

void main()
{
float i=1.5;
switch(i)
{
case 1: printf("1");
case 2: printf("2");
default : printf("0");
}
}

A. 1 2 0
B. 2
C. Compiler error: switch quantity not an integer
D. 1
Answer:C

91. How many times "Nagarro" will get printed?


int main()
{
int x;

for (x=-1; x<10;x++)
{
if (x<5)
continue;
else
break;
printf("Nagarro");
}
return 0;
}

A. Infinite times
B. 11 times
C. 0 times
D. 10 times
Answer:C
92. The use of the break statement in switch statement is

A. optional
B. compulsory
C. not allowed. It gives an error message
D. to check an error
Answer:A
93. The type of the controlling statement of a switch statement cannot be of the type

A. int
B. char
C. short
D. float
Answer:D
94. What will be the O/P?

void main()
{
int i=0;
switch(i){
case 0 : printf("%d",i);break;
case 1 : printf("%d",i);break;
}
}

A. Compile-time error
B. 0
C. 1
D. Run-time error
Answer:B
95. Given the following C program, which one of the alternatives is correct?

main()
{
char status;
int balance;
balance = 1000;
status= (balance>= 1000)? 'C': 'O'
}

A. status = 'O'
B. status= 'C'
C. status= O;
D. status = NIL
Answer:B
96. What is the output of the following program?

void main()
{
int B, X, Y, Z;
X=1; Y=2; Z=3;
jf ((X > 1) || (Y > 1))
if (Z > 1)
printf ("O.K /n");
else break;
if((X > 1 && (Z > 3))
printf ("Bye /n");
printf ("Hello!");
}

A. O.K. bye
B. Bye.
C. O.K. Hello
D. Hello.
Answer:A

97. 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
Answer:B
98. What would be the output of below program if choice = 'R' ?

void main() {
switch (choice) {
case 'R': printf("RED");
case 'W': printf("WHITE");
case 'B' : prinf ("BLUE");
default: printf("ERROR");
break;
}

A. RED
B. RED ERROR
C. RED WHITE BLUE ERROR
D. RED WHITE BLUE
Answer:B
99. What is the output of the below fragment of C code, if i = 3?

if (i >1)c = 2;
else c = 3;
switch (c) {
case 2: printf("CAUTION");
break;
case 3: printf("GOOD BYE");
break;
default : printf("TERROR");
}

A. CAUTION
B. GOOD BYE
C. ERROR
D. Default
Answer:A

100. Consider the following C program fragment.

if (marks > 80)
grad = 'A';
else if ((marks > 70) && (attendance > 75 ))
grade= 'B';
else if (attendanc < 75)
grade = 'R';
if ((marks > 60) && (attendance > 50))
grade= 'F';
else
grade = 'E'

What is the value of grade if marks = 565 and attendance = 80?

A. A
B. B
C. F
D. E
Answer:D

101. A continue statement causes execution to skip to

A. the return 0; statement
B. the first statement after the loop
C. the statement following the continue statement
D. the next iteration of the loop
Answer:C
102. The call zap(6) gives the values of zap

int zap(int n){
if(n<=1)then zap=1;
else zap=zap(n-3)+zap(n-1);
}

A. 8
B. 9
C. 6
D. 12
Answer:B
103. Point out the error in the program


int f(int a){
a > 20? return(10): return(20);
}
int main(){
int f(int);
int b;
b = f(20);
printf("%d\n",B);
return 0;
}

A. Error: Prototype declaration
B. No error
C. Error: return statement cannot be used with conditional operators
D. None of these
Answer:C
104. func()
{
int x=1;
if(x=1)
x=1000;
else
x=10;
return x;
}
What is the return value?

A. 1
B. 10
C. 1000
D. Error
Answer:C
105. What will be the result of the following program?

int main()
{
int ones, twos, threes, others;
int c;
ones = twos = threes = others = 0;
while ((c = getchar ()) != EOF)
{
switch (c)
{
case '1': ++ones;
case '2': ++twos;
case '3': ++threes;
break;
default: ++others;
break;
}
}
printf ("%d %d", ones, others);
return 0;
}

A. 1 1
B. 3 4
C. 3 2
D. 3 3
Answer:D
106. What will be output of following c program?

int main(){
int i=0;
for(i=0;i<20;i++){
switch(i){
case 0:i+=5;
case 1:i+=2;
case 5:i+=5;
default: i+=4; break;
}
printf("%d ",i);
}
return 0;
}

A. 0 5 9 13 17
B. 5 9 13 17
C. 12 17 22
D. 16 21
Answer:D

107. What will be output of following c program?


int main(){
char c=-64;
int i=-32;
unsigned int u =-16;
if(c>i){
printf("pass1");
if(c printf("pass2");
else
printf("Fail2");
}
else
printf("Fail1?);

if(c==i)
printf("pass2");
else
printf("Fail2");
return 0;
}

A. Pass1Pass2
B. Pass1Fail2
C. Fail1Pass2
D. Fail1Fail2
Answer:D

108. int a = 0, b = 2;
if (a = 0)
b = 0;
else
b *= 10;

What is the value of b?

A. 0
B. 20
C. 2
D. None of the above
Answer:B
109. int x = 2, y = 2, z = 1;

What is the value of x after the following statmements?

if (x = y%2)
z = x;
else
z=y;

A. 0
B. 2
C. 1
D. Compilation Error
Answer:A
110. Comment on the output of this C code?

int main()
{
int a = 1;
switch (a)
case 1:
printf("%d", a);
case 2:
printf("%d", a);
case 3:
printf("%d", a);
default:
printf("%d", a);
}

A. No error, output is 1111
B. No error, output is 1
C. Compile time error, no break statements
D. Compile time error, case label outside switch statement
Answer:D

111. What is the output of the following 'C' program ?

int main()
{
int i=10;

switch(i) {
case 10: printf("Hello "); {
case 1 : printf("World ");
}
case 5: printf("Hello World ");
}
}

A. Hello
B. World
C. Hello World Hello World
D. Syntax Error

Answer:C

112. Predict the output of following code:


void main()
{
int a=2;
switch(a)
{
case 1: printf("one");
case 2: printf("Two");
case 3: printf("Three");
default:printf("Invalid option");
}
}

A. onetwothree
B. Invalid option
C. one two
D. TwoThreeInvalid option

Answer:D
113. Predict the output of following "C" code:

main()
{
int a=100,b=300;
if(a>50)
a=200;
b=400;
printf("%d",b);
}

A. 400
B. 300
C. 100
D. Error
Answer:A
114. Predict the output of following "C" code:

void main()
{
if(printf("O", printf("Two")))
printf("Face");
else
printf("Focus");
}

A. Error
B. OTwoFace
C. HaiFocus
D. TwoOFace
Answer:D

115. Predict the output of following "C" code:

void main()
{
if( printf("Hai"))
printf("Face");
else
printf("Focus");
}

A. Error
B. HaiFace
C. HaiFocus
D. Face
Answer:B
116. Predict the output of following "C" code:

void main()
{
if(5,4,3,2,1,0,8,9)
printf("True");
else
printf("False");
}

A. TRUE
B. FALSE
C. True False
D. Error
Answer:A

117. Predict the output of following "C" code:

void main()
{
if(5,4,3,2,1,? 0 ? )
printf("True");
else
printf("False");
}

A. TRUE
B. FALSE
C. True False
D. Error
Answer:B
118. Predict the output of following "C" code:

void main()
{
if(1)
printf("hai");
else
printf("hello");
}

A. Error
B. hai
C. hello
D. No output
Answer:A
119. Predict the output of following "C" code:

void main()
{
int a,x=2,3,4,5;
a=1,2,3,4,5;
printf("%d%d",x,a);
}

A. Error
B. 5,1
C. 2,1
D. 5,5
Answer:A
120. Predict the output of following "C" code:

void main()
{
int a,x=(2,3,4,5);
a=1,2,3,4,5;
printf("%d,%d",x,a);
}

A. Error
B. 5,1
C. 2,1
D. 5,5
Answer:B

121. What is the output of the following program ?
int main() {
union {
int a;
int b;
int c;
} u,v;
u.a = 10;
u.b = 20;
printf("%d %d \n",u.a,u.b);
return 0;
}

A. 20 20
B. 10 10
C. 10 20
D. 20 10
Answer:A

122. What is the output of the following problem ?

struct {
int x;
int y;
union {
int id_no;
char *name;
}b;
}s,*st;
int main()
{
st = &s;
st->x=10;
st->b.id_no = 101;
printf("%d %d\n",s.x,s.b.id_no);
return 0;
}

A. 10 10
B. 101 101
C. 10 101
D. Noneof these
Answer:C

123. What is the output of the following program ?
void main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s=malloc(sizeof(struct xx));
printf("%d",s->x);
printf("%s",s->name);
}

A. 3 hello
B. Garbage value hello
C. 3 Garbage Value
D. Compiler Error
Answer:D

124. What is the output of the following 'C' program ?
struct myStruct{
int a;
char b;
}*ptr;
int main(){
struct myStruct ms={400,'A'};
printf("%d %d",ptr->a,ptr->b);
return 0;
}

A. 400 A
B. 400 65
C. 400 97
D. 0 0
Answer:D

125. What is the output of the following 'C' program ?


typedef struct stu1{
char name1[6];
char name2[6];
double marks;
}STU1;
void main(){
STU1 s1={"rohit","kumar",87.43},*p1;
char *p;
p1=&s1;
p=memchr(p1,'u',sizeof(STU1));
printf("%s",p);
}

A. roh
B. rohit
C. umar
D. rohit kumar
Answer:C

126. What is the output of the following 'C' program?

void main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d",s->x);
printf("%s",s->name);
}

A. 3 hello
B. Garbage Value
C. Compilation error
D. None of these
Answer:C


127. What is the output of the following 'C' program?

void main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}

A. No Error
B. Compiler Error
C. RunTime error
D. None of these
Answer:B

128. What is the output of the following 'C' program?
enum colors {BLACK,BLUE,GREEN,YELLOW};
int main()
{
printf("%d..%d..%d..%d",BLACK,BLUE,GREEN,YELLOW);
return 0;
}

A. 0..2..3..4
B. 0..2..2..3
C. 0..1..2..3
D. None of these
Answer:D


129. What is the output of the following 'C' program?


enum colors {BLACK,BLUE=2,GREEN,YELLOW};
int main()
{
printf("%d..%d..%d..%d",BLACK,BLUE,GREEN,YELLOW);
return 0;
}

A. 0..2..3..4
B. 0..2..2..3
C. 0..1..2..3
D. None of these
Answer:A
130. What is the output of the following 'C' program?

enum colors {BLACK,BLUE=-2,GREEN,YELLOW};
int main()
{
printf("%d..%d..%d..%d",BLACK,BLUE,GREEN,YELLOW);
return 0;
}

A. 0..2..3..4
B. 0..-2..-1..0
C. 0..1..2..3
D. 0..-2..1..2
Answer:B

131. What is the output of the following 'C' program?

struct point
{
int x;
int y;
};
struct point origin,*pp;
int main()
{
pp=&origin;
printf("origin is(%d%d)\n",(*pp).x,(*pp).y);
printf("origin is (%d%d)\n",pp->x,pp->y);
return 0;
}

A. Compilation Error
B. origin is(1,1) origin is(1,1)
C. origin is(0,0) origin is(0,0)
D. None of these
Answer:C

132. What is the output of the following 'C' program?


void 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. 0
C. Garbage values
D. 1 0.000000
Answer:B
133. What error are you likely to get when you run the following program?

void main() {
struct emp
{
char name[20];
float sal;
};
struct emp e[10];
int i;
for(i=0;i <= 1; i++)
scanf("%s%f", e[i].name, & e[i].sal);
}

A. Suspicious pomter conversion
B. Cannot use scanf() for structures
C. Strings cannot be nested inside structures
D. No Error
Answer:D
134. What is the output of the following program ?

struct aaa{
struct aaa *prev;
int i;
struct aaa *next;
};
void main()
{
struct aaa abc,def,ghi,jkl;
int x=100;
abc.i=0;
abc.prev=&jkl;
abc.next=&def;
def.i=1;def.prev=&abc;
def.next=&ghi;
ghi.i=2;ghi.prev=&def;
ghi.next=&jkl; jkl.i=3;
jkl.prev=&ghi;
jkl.next=&abc;
x=abc.next->next->prev->next->i;
printf("%d",x);
}

A. 4
B. 3
C. Compilation Error
D. 2
E. None of these
Answer: D
135. What is the output of the following program ?

void main()
{
enum {i=10,j=20,k=50};
printf("%d",++k);
}

A. Compilaiton Error: Lvalue required
B. 51
C. 50
D. None of these
Answer:A
136. What is the output for the program given below


typedef enum errorType{warning, error, exception,}error;
void main()
{
error g1;
g1=1;
printf("%d",g1);
}

A. 3
B. 2
C. 1
D. error: ?error? redeclared as different kind of symbol
E. None of these
Answer:D
137. What is the output of the following program ?
typedef struct error
{
int warning, error, exception;
}error;
void main()
{
error g1;
g1.error=1;
printf("%d",g1.error);
}

A. 1
B. Compilation Error
C. 0
D. 2
E. None of these
Answer:A
138. What will be output of the following "c" code?

void main()
{
struct date;
struct student
{
char name[30];
int rollno;
struct date dob;
}stud;

struct date
{
int day,month,year;
};
scanf("%s%d%d%d",stud.rollno,&student.dob.day,&student.dob.month,&student.dob.year);
}

A. No Output No Error
B. Compiler Error: Undefined structure date
C. will take the given input
D. None of these
Answer:B
139. What is the output of the following 'C' program ?
int main()
{
struct sample
{
int a:6;
int b:12;
char s;
}st;

struct name
{
int a:28;
int b:12;
char ch;
}st1;

printf("%d %d",sizeof(st),sizeof(st1));
return 0;
}


A. 4 8
B. 4 4
C. 8 8
D. 12 12
E. 8 4
Answer:A
140. What will be the size of these structures?


struct S1 {
char c;
int i[2];
double v;
} SA1;
struct S2 {
double x;
int i[2];
char c;
} SA2;
int main()
{
printf("\n sizeof S1 %d : Sizeof S2 %d ",sizeof(SA1),sizeof(SA2));
return 0;
}


A. sizeof S1 12 : Sizeof S2 12
B. sizeof S1 20 : Sizeof S2 20
C. sizeof S1 13 : Sizeof S2 13
D. Compilation Error
Answer:B

141. What is the final value of i and final value of LOOPS ?

int main()
{
int i,j,k,l,lc=0;

printf("Enter the number string:<1234 567>\n");
scanf("%2d%d%1d",&i,&j,&k);
for(;k;k--,i++)
for(l=0;printf("%d %d\n",i,l);)
printf("LOOPS= %d\n", lc-1);
}

A. I = 16 and LOOPS=169
B. I = 0 and LOOPS=16
C. Compilation Error
D. No output
Answer:A

142. What is the output of the following problem ?

int main()
{
int i;
for (i=9;i<13; i++)
printf("%d %0x ",i,i);
return 0;
}

A. 9 9 10 10 11 11 12 12
B. 9 10 11 12
C. 9 9 10 b 11 b 12 c
D. Compilation Error
E. 9 9 10 a 11 b 12 c
Answer:E
143.
int main(){
for(printf("1");!printf("0");printf("2"))
printf("Aditya");
return 0;
}

A. 10Aditya2
B. 10Aditya
C. 10Aditya210Aditya2
D. 10
E. Compilation error
Answer:D
144. void main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q;
}
for(j=0;j<5;j++){
printf(" %d ",*p);
++p;
}
}

A. 2 3 4 6 5 2 3 4 6 5
B. 2 2 2 2 2 2 3 4 6 5
C. 2.8 3.4 4 6.7 5 2.8 3.4 4 6.7 5
D. None of these
E. Compiler Error
Answer:B
145. What is the output of the following C Program?


int main()
{
int i=0;
for(;i++;printf("%d",i)) ;
printf("%d",i);
return 0;
}

A. 0
B. 1
C. 2
D. None of these
Answer:B
146. What is the output of the following C Program?


int main()
{
unsigned int i;
for(i=1;i>-2;i--)
printf("c aptitude");
}

A. c aptitude
B. c aptitude three time
C. no output No Error
D. Compilation Error
E. None of these
Answer:C
147. What is the output of the following C Program?

void main()
{
while(1){
if(printf("%d",printf("%d")))
break;
else
continue;
}
}

A. Garbage values
B. Compilation Error
C. no output No Error
D. stack Overflow
Answer:A
148. What is the output of the following C Program?


void main()
{
signed char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}

A. 256
B. 128
C. -256
D. -128
E. Compilation Error
Answer:D
149. What will be output of the following "c" code?
int main() {
int i;
for(i=0;i<5;i++){
int i=10;
printf(" %d",i);
i++;
}
return 0;
}

A. 10 11 12 13 14
B. 10 10 10 10 10
C. 0 1 2 3 4
D. Infinite loop
Answer:B
150. Find out the error in the 'while' loop, if any ?

void main()
{
int i= 1;
while ()
{
printf("%d", i++);
if (i > 10)
break;
}
}

A. The condition in the while loop is a must
B. There should be at least a semicolon in the while ()
C. The while loop should be replaced by for loop
D. No error
Answer:A

151. What is the output of the following program ?

void main()
{
for (putchar('c');putchar('a');putchar('r'))
putchar('t');
}

A. syntax error
B. catrat
C. catTatratratrat...
D. cartrt
Answer:C

152.
void main() {
int i,j;
for(i=0;i<=10;i++)
{
j+=5;
assert(i<5);
}}

A. Runtime error: Abnormal program termination.
B. Compilatin Error
C. No Ouptput No error
D. None of these
Answer:A
153.
int i;
void main(){
int t;
for ( t=4;scanf("%d",&i)-t;printf("%d\n",i))
printf("%d--",t--);
}
// If the inputs are 1,2,3 find the o/p

A. Compilation Error
B. 4--1 3--0 2--2
C. Run time Error
D. 4--0 3--1 2--2
E. None of these
Answer:D
154.
void main()
{
int i=0;
while(+(+i--)!=0)
i-=i++;
printf("%d",i);
}

A. 2
B. Compilation Error
C. 0
D. 1
E. -1
Answer:E
155.
void main()
{
char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}

A. -128
B. infinite loop
C. 1 2 3 4
D. None of these
E. Compilation Error
Answer:A
156.
void main()
{
int i = 3;
for (;i++=0;)
printf("%d",i);
}

A. 3 4 5
B. 3 4 5 ? continue
C. Compiler Error: Lvalue required.
D. None of these
Answer:C
157. What is the output of the following 'C' program?

void main()
{
static int i;
while(i<=10)
(i>2)?i++:i--;
printf("%d", i);
}

A. Garbage Value
B. Compilation Error
C. 0
D. 2147483647
E. None of these
Answer:D
158. What will be output of the following "c" code?
void main()
{
char ch;
for(ch=0;ch<=127;ch++)
printf("%c %d \n", ch, ch);
}

A. Infinte loop
B. 0-127 char
C. Compilation Error
D. None of these
Answer:A
159. What is the output of the following 'C' program ?
int main()
{
int c = 0;
do
{
int c = 0;
++c ;
printf("\n c = %d ", c );
}
while( ++c <= 3 );
printf("\n c = %d\n", c );
return 0;
}

A. c = 1 c = 1 c = 1 c = 1 c = 4
B. c = 1 c = 1 c = 1 c = 4 c = 4
C. Compilation Error
D. None of these
Answer:A
160. What is the output of the following 'C' program ?

int main()
{
int i;
for (i = 0; i < 3; ++i)
{
int t = 1;
static int i = 1;
int *ptr = &i;
printf("%d %d\n",t, *ptr);
t = t + 1;
*ptr = *ptr + 1;
}
return 0;
}

A. 1 0 1 1 1 2
B. 1 1 1 2 1 3
C. 1 0 1 0 1 0
D. Compilation Error
Answer:B

161. Who is father of C Language?
A. Bjarne Stroustrup
B. Dennis Ritchie
C. James A. Gosling
D. Dr. E.F. Codd
Answer : B

162. C Language developed at _____?
A. AT & T’s Bell Laboratories of USA in 1972
B. AT & T’s Bell Laboratories of USA in 1970
C. Sun Microsystems in 1973
D. Cambridge University in 1972
Answer : A

163. For 16-bit compiler allowable range for integer constants is ______ ?
A. -3.4e38 to 3.4e38
B. -32767 to 32768
C. -32768 to 32767
D. -32668 to 32667
Answer : C

164. C programs are converted into machine language with the help of ______.
A. An Editor
B. A compiler
C. An operating system
D. None of the above
Answer : B

165. A C variable cannot start with
A. An alphabet
B. A number
C. A special symbol other than underscore
D. both (b) and (c)
Answer : D

166. Which of the following is allowed in a C Arithmetic instruction
A. []
B. {}
C. ()
D. None of the above
Answer : C

167. Which of the following shows the correct hierarchy of arithmetic operations in C
A. / + * –
B. * – / +
C. + – / *
D. * / + –
Answer : D

168. What is an array?
A. An array is a collection of variables that are of the dissimilar data type.
B. An array is a collection of variables that are of the same data type.
C. An array is not a collection of variables that are of the same data type.
D. None of the above.
Answer : B

169. What is right way to Initialization array?
A. int num[6] = { 2, 4, 12, 5, 45, 5 } ;
B. int n{} = { 2, 4, 12, 5, 45, 5 } ;
C. int n{6} = { 2, 4, 12 } ;
D. int n(6) = { 2, 4, 12, 5, 45, 5 } ;
Answer : A

170. An array elements are always stored in _________ memory locations.
A. Sequential
B. Random
C. Sequential and Random
D. None of the above
Answer : A

171. What is the right way to access value of structure variable book{ price, page }?
A. printf(“%d%d”, book.price, book.page);
B. printf(“%d%d”, price.book, page.book);
C. printf(“%d%d”, price::book, page::book);
D. printf(“%d%d”, price->book, page->book);
Answer : A

172. perror( ) function used to ?
A. Work same as printf()
B. prints the error message specified by the compiler
C. prints the garbage value assigned by the compiler
D. None of the above
Answer : B

173. Bitwise operators can operate upon?
A. double and chars
B. floats and doubles
C. ints and floats
D. ints and chars
Answer : D

174. What is C Tokens?
A. The smallest individual units of c program
B. The basic element recognized by the compiler
C. The largest individual units of program
D. A & B Both
Answer : D

175. What is Keywords?
A. Keywords have some predefine meanings and these meanings can be changed.
B. Keywords have some unknown meanings and these meanings cannot be changed.
C. Keywords have some predefine meanings and these meanings cannot be changed.
D. None of the above
Answer : C

176. What is constant?
A. Constants have fixed values that do not change during the execution of a program
B. Constants have fixed values that change during the execution of a program
C. Constants have unknown values that may be change during the execution of a program
D. None of the above
Answer : A

177. Which is the right way to declare constant in C?
A. int constant var =10;
B. int const var = 10;
C. const int var = 10;
D. B & C Both
Answer : D

178. Which operators are known as Ternary Operator?
A. ::, ?
B. ?, :
C. ?, ;;
D. None of the avobe
Answer : B

179. In switch statement, each case instance value must be _______?
A. Constant
B. Variable
C. Special Symbol
D. None of the avobe
Answer : A

180. What is the work of break keyword?
A. Halt execution of program
B. Restart execution of program
C. Exit from loop or switch statement
D. None of the avobe
Answer : C

181. What is function?
A. Function is a block of statements that perform some specific task.
B. Function is the fundamental modular unit. A function is usually designed to perform a specific task.
C. Function is a block of code that performs a specific task. It has a name and it is reusable
D. All the above
Answer : D
182. Which one of the following sentences is true ?
A. The body of a while loop is executed at least once.
B. The body of a do … while loop is executed at least once.
C. The body of a do … while loop is executed zero or more times.
D. A for loop can never be used in place of a while loop.
Answer : B

183. A binary tree with 27 nodes has _______ null branches.
A. 54
B. 27
C. 26
D. None of the above
Answer : D

184. Which one of the following is not a linear data structure?
A. Array
B. Binary Tree
C. Queue
D. Stack
Answer : B

185. Recursive functions are executed in a?
A. First In First Out Order
B. Load Balancing
C. Parallel Fashion
D. Last In First Out Order
Answer : D

186. Queue is a _____________ list.
A. LIFO
B. LILO
C. FILO
D. FIFO
Answer : D

187. The statement print f (“%d”, 10 ? 0 ? 5 : 1 : 12); will print?
A. 10
B. 0
C. 12
D. 1
Answer : D

188. To represent hierarchical relationship between elements, which data structure is suitable?
A. Priority
B. Tree
C. Dqueue
D. All of the above
Answer : B

189. Which of the following data structure is linear type?
A. Strings
B. Queue
C. Lists
D. All of the above
Answer : D

180. The statement printf(“%c”, 100); will print?
A. prints 100
B. print garbage
C. prints ASCII equivalent of 100
D. None of the above
Answer : C

181. The _______ memory allocation function modifies the previous allocated space.
A. calloc
B. free
C. malloc
D. realloc
Answer : D

182. Number of binary trees formed with 5 nodes are
A. 30
B. 36
C. 108
D. 42
Answer : D

183. The “C” language is
A. Context free language
B. Context sensitive language
C. Regular language
D. None of the above
Answer : A

184. The worst case time complexity of AVL tree is better in comparison to binary search tree for
A. Search and Insert Operations
B. Search and Delete Operations
C. Insert and Delete Operations
D. Search, Insert and Delete Operations
Answer : D

185. In which tree, for every node the height of its left subtree and right subtree differ almost by one?
A. Binary search tree
B. AVL tree
C. Threaded Binary Tree
D. Complete Binary Tree
Answer : B

186. C is ______ Language?
A. Low Level
B. High Level
C. Assembly Level
D. Machine Level

187. The Default Parameter Passing Mechanism is called as
A. Call by Value
B. Call by Reference
C. Call by Address
D. Call by Name
Answer : A

188. What is Dequeue?
A. Elements can be added from front
B. Elements can be added to or removed from either the front or rear
C. Elements can be added from rear
D. None of the above
Answer : B

189. In which linked list last node address is null?
A. Doubly linked list
B. Circular list
C. Singly linked list
D. None of the above
Answer : C

190. Which is the correct syntax to declare constant pointer?
A. int *const constPtr;
B. *int constant constPtr;
C. const int *constPtr;
D. A and C both
Answer : D

191. What will be the output of the following arithmetic expression ?
5+3*2%10-8*6
a) -37
b) -42
c) -32
d) -28
Ans: a

192. What will be the output of the following statement ?
int a=10; printf(“%d &i”,a,10);
a) error
b) 10
c) 10 10
d) none of these
Ans: d

193. What will be the output of the following statement ?
printf(“%X%x%ci%x”,11,10,’s’,12);
a) error
b) basc
c) Bas94c
d) none of these
Ans: b

194. What will be the output of the following statements ?
int a = 4, b = 7,c; c = a = = b; printf(“%i”,c);
a) 0
b) error
c) 1
d) garbage value
Ans: a

195. What will be the output of the following statements ?
int a = 5, b = 2, c = 10, i = a>b
void main()
{ printf(“hello”); main(); }
a) 1
b) 2
c) infinite number of times
d) none of these
Ans: c

196. What will be output if you will compile and execute the following c code?
struct marks{
int p:3;
int c:3;
int m:2;
};
void main(){
struct marks s={2,-6,5};
printf(“%d %d %d”,s.p,s.c,s.m);
}
(a) 2 -6 5
(b) 2 -6 1
(c) 2 2 1
(d) Compiler error
(e) None of these
Ans: c

197. What will be the output of the following statements ?
int x[4] = {1,2,3}; printf(“%d %d %D”,x[3],x[2],x[1]);
a) 03%D
b) 000
c) 032
d) 321
Ans: c

198. What will be the output of the following statement ?
printf( 3 + “goodbye”);
a) goodbye
b) odbye
c) bye
d) dbye
Ans: d

199. What will be the output of the following statements ?
long int a = scanf(“%ld%ld”,&a,&a); printf(“%ld”,a);
a) error
b) garbage value
c) 0
d) 2
Ans: b

200. What will be the output of the following program ?

void main()
{ int a = 2;
switch(a)
{ case 1:
printf(“goodbye”); break;
case 2:
continue;
case 3:
printf(“bye”);
}
}
a) error
b) goodbye
c) bye
d) byegoodbye
Ans: a

201. What will be the output of the following statements ?
int i = 1,j; j=i— -2; printf(“%d”,j);
a) error
b) 2
c) 3
d) -3
Ans: c

202. What will be the output of following program ?

main()
{
int x,y = 10;
x = y * NULL;
printf(“%d”,x);
}
a) error
b) 0
c) 10
d) garbage value
Ans: b

203. What will be the output of following statements ?
char x[ ] = “hello hi”; printf(“%d%d”,sizeof(*x),sizeof(x));
a) 88
b) 18
c) 29
d) 19
Ans: d

204. What will be the output of the following statements ?
int a=5,b=6,c=9,d; d=(ac?1:2):(c>b?6:8)); printf(“%d”,d);
a) 1
b) 2
c) 6
d) Error
Ans: d

205. What will be the output of the following statements ?
int i = 3;
printf(“%d%d”,i,i++);
a) 34
b) 43
c) 44
d) 33
Ans: b

206. What will be the output of the following program ?
#include
void main()
{
int a = 36, b = 9;
printf(“%d”,a>>a/b-2);
}
a) 9
b) 7
c) 5
d) none of these
Ans: a

207. int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
What value does testarray[2][1][0] in the sample code above contain?
a) 11
b) 7
c) 5
d) 9
Ans: a

208. void main()
{
int a=10,b=20;
char x=1,y=0;
if(a,b,x,y)
{
printf(“EXAM”);
}
}
What is the output?
a) XAM is printed
b) exam is printed
c) Compiler Error
d) Nothing is printed
Ans: d

209. What is the output of the following code?

void main()
{
int s=0;
while(s++<10)>
# define a 10
main()
{
printf(“%d..”,a);
foo();
printf(“%d”,a);
}
void foo()
{
#undef a
#define a 50
}
a) 10..10
b) 10..50
c) Error
d) 0
Ans: c

210. main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf(“%d”,xyz.i);
}
What is the output of this program?
a) program will not compile
b) 10
c) god only knows
d) address of I
Ans: b

211.What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?
A. The element will be set to 0.
B. The compiler would report an error.
C. The program may crash if some important data gets overwritten.
D. The array size would appropriately grow.
Ans: C

212. What would be the output of the following program?

main()
{
char str[]=”S\065AB”;
printf(“\n%d”, sizeof(str));
}
a) 7
b) 6
c) 5
d) error
Ans: b

213. What will be the value of `a` after the following code is executed
#define square(x) x*x
a = square(2+3)
a) 25
b) 13
c) 11
d) 10
Ans: c

214.
void func()
{
int x = 0;
static int y = 0;
x++; y++;
printf( “%d — %d\n”, x, y );
}
int main()
{
func();
func();
return 0;
}
What will the code above print when it is executed?
a)
1 — 1
1 — 1
b)
1 — 1
2 — 1
c)
1 — 1
2 — 2
d)
1 — 1
1 — 2
Ans: d

215. Which of the following C statements is syntactically correct ?

A. for ( );
B. for(;);
C. for(,);
D. for (;;);
Answer :D

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

A. it is assumed to be present and taken to be false
B. it is assumed to be present and taken to the true
C. it result in a syntax error
D. execution will be terminated abruptly
Answer :B
217. What is the output of the following C Program?

void main() {
for(i = 1; i < 5; i++)
{
if (i == 3)
continue;
else
printf ("%d", i);
}
}

A. 1 2 4 5
B. 1 2 4
C. 2 4 5
D. none of these
Answer :B
218. What is the output of the following C Program?

void main()
{
for (i = 3; i < 15; i += 3);
printf ("%d", i);
}

A. a syntax error
B. an execution error
C. 12
D. 15
Answer :D
219. What is the output of the following program ?
void main()
{
int i= 5;
do {
putchar (i + 100);
printf("%d", i--);
}while(i);
}

A. i5h4g3flel
B. 14h3g2fle0
C. an error message
D. none of these
Answer :A
220. What is the output of the following C Program?

void main()
{
for (i =1,j = 10; i < 6; ++i, - -j)
printf("%d%d", i,j);
}

A. 1 10 2 9 3 8 4 7 5 6
B. 1 2 3 4 5 10 9 8 7 6
C. 1 1 1 1 1 9 9 9 9 9
D. none of these
Answer :A
221. What is the output of the following C Program?
void main()
{
for (i = 3; i < 15; i += 3);
printf ("%d", i);
}

A. a syntax error
B. an execution error
C. 12
D. 15
Answer :D
222. Which of the following statements about for loop are correct?

A. Index value is retained outside the loop
B. Index value can be changed from within the loop
C. Goto can be used to jump, out of the loop
D. All of these
Answer :D
223. What is the output of the following program ?

int main()
{
int i,j;
i = j =2;
while ( --i && j++)
printf("%d %d",i,j);

return 0;
}

A. 2 3
B. 0 3
C. 1 3
D. Infinite Loop
Answer :C
224. What will be output of the following "c" code?
void main()
{
int i= 0;
for(; i++; printf("%d", i));
printf("%d", i);
}

A. 1 1
B. 0
C. infinite loop
D. 1
E. None of these
Answer :D

0 Comments