100% found this document useful (1 vote)
2K views22 pages

345 FAQS With Ans

The document is a 22 question C language FAQ. It provides code snippets and explanations for common C programming questions. Some key points: - Questions cover basic syntax, operators, data types, expressions and their evaluation order. - Sample outputs show how C evaluates expressions step-by-step and the values of variables after execution. - Answers explain the behavior of code like precedence of operators, implicit type conversions, side effects of expressions. - It serves as a reference for beginners to understand fundamentals of C and debug their own programs.

Uploaded by

Nihit Kapoor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views22 pages

345 FAQS With Ans

The document is a 22 question C language FAQ. It provides code snippets and explanations for common C programming questions. Some key points: - Questions cover basic syntax, operators, data types, expressions and their evaluation order. - Sample outputs show how C evaluates expressions step-by-step and the values of variables after execution. - Answers explain the behavior of code like precedence of operators, implicit type conversions, side effects of expressions. - It serves as a reference for beginners to understand fundamentals of C and debug their own programs.

Uploaded by

Nihit Kapoor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

C Language FAQ’s Page 1 of 22

1. What is the output of the following code? void main()


void main() {
{ int x=5,y=7;
int x; printf("%d\n",y/x);
x = 3 > 2 > 1; }
printf("%d" , x); Ans: 1
} 11. What is the output of the following code?
Ans: 0 void main()
2. What is the output of the following code? {
void main() clrscr();
{ printf("%d", 5?2?0?8:9:7:3);
printf("%X" , -1<<4); }
} Ans: 9
Ans: FFF0 12. What is the output of the following code.
3. What is the output of the following code? void main()
void main() {
{ int i = 10;
int c = - -2; i = !i > 14;
printf("c=%d",c); printf("i = %d",i);
} }
Ans: 2 Ans: 0
4. What is the output of the following code? 13. What is the output of the following code.
void main() void main()
{ {
int i=5; int a,b,c;
printf("%d%d%d%d%d" , i++,i--,++i,--i, i); a=4;
} b=7;
Ans: 4 5 5 4 5 c=a==b;
5. What is the output of the following code? printf("%i",c);
void main() }
{ Ans: 0
int i; 14. what is the output of the following C program?
printf("%d" , scanf("%d",&i)); // value 10 is given as input here void main()
} {
Ans: 1 int y = 128;
6. What is the output of the following code? const int x = y;
void main() printf("%d",x);
{ }
int i=5; Ans: 128
printf("%d",++i++); 15. What is the output of the following code.
} void main()
Ans: Compile time – Error [ Lvalue required] {
7. What is is the output of the following code? int i=12345;
void main() clrscr();
{ printf("%2d",i);
int i; }
i = 10 + 010 + 0x20; Ans: 12345
printf("%d ", i); 16. What is the output of the following code.
} void main()
Ans: 50 {
8. What is the output of the following code? int x=2,y=6,z=6;
void main() x = y == z;
{ printf(“%d",x);
clrscr(); }
printf("%d",printf("Hello")); Ans: 1
} 17. What is the output of the following program.
Ans: Hello 5 void main()
9. What is the output of the following code? {
void main() int x,j,k;
{ j=k=6;
int x,y; x=2;
clrscr(); x=j*k;
printf("%d",scanf("%d%d",&x,&y)); printf("%d", x);
} }
Ans: 2 Ans:36
10. What is the output of the following code? 18. What is the output of the following program?
C Language FAQ’s Page 2 of 22

void main() printf("c=%d\n",c);


{ }
int x; Ans: c = 1
x = 11 ^ 5; 28. What is the output of the following code?
printf("%d" , x); void main()
} { printf("\n%d,%d,%d,%d",printf("\na"),printf("\nab"),
Ans: 14 printf("\nabc"),printf("\nabcd"));
19. Which keyword is used to define constants in 'C'? }
a.final b.const c.typedef d.enum Ans: abcd
Ans: const abc
20. What is the output of the following code. ab
printf ("%d", 3>2?(4<5?4:5):3); a
Ans: 5 2, 3, 4, 5
21. What is the output of the following code. 29. What is the output of the following code?
void main() void main()
{ {
printf(“%c”, ‘1’ + 1); int a;
} a = (1,2,3,4,5);
a. ASCII value of ‘1’ is required to find out the answer printf("\n a = %d",a);
b. 2 c. 50 d. Syntax error }
Ans: 2 Ans: a = 5
22. Which of the following are unary operators in C? 30. What is the output of the following code?
A. ! B. sizeof C. ~ D. && E. = void main()
Ans: A B, C {
23. What is the output of the following code? int a;
int main() a = 1,2,3,4,5;
{ printf("\n a = %d",a);
int x = 4, y, z; }
y = --x; Ans: a = 1
z = x--; 31. What is the output of the following code?
printf("%d%d%d\n",x,y,z); void main()
return 0; {
} int a,x=5;
A. 4 3 3 B. 4 3 2 C. 3 3 2 D. 2 3 3 E. 2 2 3 a = (x++,++x,--x);
Ans: 2 3 3 printf("\n a = %d",a);
24. What will be the output of the following program? printf("\n x = %d",x);
int main() }
{ Ans: a = 6
int i = 2; x=6
int j = i + (1,2,3,4,5); 32. What is the output of the following code?
printf("%d\n", j); void main()
return 0; {
} int a = 010;
Ans: 7 printf("\n a = %d ", a);
25. Which of the following is the correct output for the }
program given below? Ans: 8
void main() 33. What is the output of the following code?
{ void main()
int x = 55; {
printf(" %d %d %d ", x>=55, x=40, x>=10); int a = 010;
} printf("\n a = %o ", a);
Ans: 0 40 1 }
26. What is the output of the following code. Ans: 10
void main() 34. What is the output of the following code?
{ void main()
int k, num=30; {
k = (num>5 ? (num<=10 ? 100 : 200) : 500); int a = 53;
printf("%d\n", k); printf("\n a = %o ", a);
} }
A. 200 B. 30 C. 100 D. 500 Ans: 65
Ans: A 35. What is the output of the following code?
27. What is the output of the following code. void main()
void main() {
{ int a = 53;
int a = 100, b = 200, c; printf("\n a = %x ", a);
c = ( a==100 || b > 200); }
C Language FAQ’s Page 3 of 22

Ans: 35 }
36. What is the output of the following program? Ans: GoodBoy 7
void main() 45. What is the output of the following code?
{ void main()
int a=5, b=3; {
printf("%d", ++(a*b+1)); printf("Work" "Hard");
} }
Ans: Compile time error [Lvalue required] Ans: WorkHard
46. What is the output of the following code?
37. What is the output of the following program? void main()
void main() {
{ int a = 5,i;
printf("%d", ++2); i = !a > 10;
} printf("i = %d", i);
Ans: Compile time error [Lvalue required] }
38. What is the output of the following code? Ans: i = 0
void main() 47. What is the output of the following code?
{ void main()
int i=0, j = 1; {
printf("%d ", i++ && ++j); char n;
printf("%d %d ", i, j); n = !2;
} printf("%d ", n);
Ans: 0 1 1 }
39. What is the output of the following code? Ans: 0
void main() 48. What is the output of the following code?
{ void main()
float c = 3.14; {
printf("%f" , c % 2); int b;
} b='b' > 'B';
Ans: Compile time error (Illegal user of Floating point) printf("%d" , b);
40. What is the output of the following code? }
#include <stdio.h> Ans: 1
main() 49. What is the output of the following code?
{ void main()
printf("%d", 'A'); {
} int x;
Ans: 65 x=20;
41. What is the output of the following code? x*=30+5;
#include <stdio.h> printf("%d", x);
void main() }
{ Ans: 700
double d = 1/2.0 - 1/2; 50. What is the output of the following code?
printf("d = %0.2lf", d); void main()
} {
Ans: 0.50 printf("%d %d", sizeof(10), sizeof(2.5));
42. What is the output of the following code? }
#include <stdio.h> Ans: 2 8
void main() 51. what is the output of the following program?
{ void main()
unsigned int c = -2; {
printf("c = %u" , c); int x = 100, y = 200;
} x>=300? y=400: y=500;
Ans: 65534 printf("%d", y);
43. What is the output of the following code? }
void main() Ans: Compiletime Error [Lvalue required]
{ 52. what is the output of the following program?
char c = 'A'; void main()
printf("%c", c + 10); {
} int x = 100, y = 200;
Ans: K x>=300? (y=400): (y=500);
44. What is the output of the following code? printf("%d", y);
void main() }
{ Ans: 500
int a = 5; 53. What is the output of the following code?
a = printf("Good") + printf("Boy"); void main()
printf("%d", a); {
C Language FAQ’s Page 4 of 22

char ch = 321; y = ( 5 > 4) == 1 ;


printf("%d %c" , ch, ch); Ans: 1
} 64. If integer num has a value 40, what will be the output of
Ans: 65 A the following code?
54. What is the output of the following code? num % 19 ? printf("Hello") : printf("Hi %d" , (num / 100) + num);
void main() A. Hello B. Hi 40.04 C.Hi 80 D. Hi 40
{ Ans: A
char ch = '\t'; 65. What is the output of the following code ?
printf("%c5", ch); void main()
} {
Ans: Tabspace 5 num = 5;
55. what is the output of the following code? printf("%d" , ++num++);
void main() }
{ Ans: Compiletime Error
int i = 97; 66. What will be the value of num after executing the
printf("%c", (char)i); following statement?
} void main()
Ans: a {
56. What is the output of the following code? Int num = 10;
void main() num/= num/= 2;
{ printf(“%d” , num);
float f = 66.6; }
printf("%c" , (char) f); Ans: 1
} 67. What is the output of the following code?
Ans: B void main()
57. What is the output of the following code? {
void main() const int c = 10;
{ printf("%d" , c++);
int i = -0777; }
printf("%d" , i); Ans: Compiletime error
} 68. What will be the value of 'a' after executing following
Ans: -511 statements?
58. What is the output of the following code? void main()
void main() {
{ int x = 1, y = 0, a;
int i = + -1234; a = ! ! x + ! y;
printf("%d" , i); printf(“%d” , a);
} }
Ans: -1234 Ans: 2
59. What is the output of the following code? 69. If the integer variable 'a' has a value 2, then after
void main() executing the following statement what will be its value?
{ --a * --a && --a || --a ;
char ch = 'A'; Ans: -1
printf("%c" , (int) ch); 70. What will be the value of variable 'a' after execution the
} following statements?
Ans: A void main()
60. What is the output of the following code ? {
void main() int a = 2;
{ if ( a-- || --a || a-- )
int i = 4; a += 1;
float f = 3; printf(“%d” , a);
printf("%d" , i/f ); }
} Ans: 2
Ans: Garbage Value 71. What is the output of the following code?
61. What is the output of the following code? void main()
void main() {
{ int a = 10 , b = 10, c;
signed char ch1 = 'Z' , ch2= 'z'; c = a+++++b;
ch1 = printf("%c%c", ch1, ch2); printf("%d %d %d " , c, a, b);
printf("%d ", ch1); }
} Ans: Compiletime error
Ans: Z z 2 72. What is the output of the following program?
void main()
62. What would be the result of the expression (-13 % 5) ? {
Ans: -3 printf("%d %d %d %d" , 10, 20, 30);
63. What will be the value of y in the following expression? }
C Language FAQ’s Page 5 of 22

Ans:10 20 30 0 Ans: w = 1 x = 0 y = 1 z = 1
73. What is the output of the following program? 81. What is the output of the following code?
void main() void main()
{ {
int j = 4, k; int x;
k = !5 && j; float y;
printf(" k = %d \n" , k); x = 5 / 2;
} y = 5 / 2;
Ans: 0 printf("%d %f" , x, y);
74. What is the output of the following code? }
void main() Ans: 2 2.0
{ 82. What is the output of the following program?
int x; void main()
x = 18.52; {
printf("%d" , x); int k = 35;
} printf("%d %d %d \n" , k == 35, k = 50, k > 40);
Ans: 18 }
75. What is the output of the following program? Ans: 0 50 0
void main() 83. What is the output of the following program?
{ void main()
int i = -1 , j = 1, k, l; {
k = !i && j; int x = 3, y, z;
l = !i || j; y = x = 10;
printf("%d %d %d %d \n" , i, j, k, l); z = x < 10;
} printf("x = %d y = %d z = %d \n" , x,y,z);
Ans: -1 1 0 1 }
76. What is the output of the following code? Ans: x = 10 y = 10 z = 0
void main() 84. What is the output of the following code?
{ void main()
printf("%d %d %d ", 10, 20, 30, 40); {
} int x,y;
Ans: 10 20 30 x = 10;
77. What is the output of the following program? y = 20;
void main() x = x + y;
{ y = x - y;
int i = -1, j = 1, k, l; x = x - y;
k = i && j; printf("x = %d y = %d" , x, y);
l = i || j; }
printf("%d %d %d %d \n" , i, j, k, l); Ans: x = 20 y = 10
} 85. What is the output of the following code?
Ans: -1 1 1 1 void main()
78. What is the output of the following code? {
void main() int x = -1;
{ printf("%d %u %o %x", x, x, x, x);
printf( " %d %d %d %d %d" , 5%2 , -5%2, 5%-2, -5%-2, 2%5); }
} Ans: -1 65535 177777 ffff
Ans: 1 -1 1 -1 2 86. The expression x = -7 % 2 - 8 is evaluates to
79. What is the output of the following program? A) -9 B) -7 C) 1 D) None of the above
void main() Ans: A
{ 87. What is the output of the following code?
int i = 4 , j = -1, k = 0, y, z; void main()
y = i + 5 && j + 1 || k + 2; {
z = i + 5 || j + 1 && k + 2; printf("%d " , -5 && 5 );
printf(" y = %d z = %d \n" , y, z); }
} Ans: 1
Ans: y = 1 z = 1 88. What is the output of the following code?
80. What is the output of the following program? void main()
void main() {
{ int y;
int i = 4, j = -1, k = 0, w, x, y, z; y = ++2;
w = i || j || k ; printf("%d" , y);
x = i && j && k; }
y = i || j && k; Ans: Compile time error
z = i && j || k; 89. The expression, a = 22/ 7 * ( 6.28 + 6.28) * 5 / 3 ; evaluates
printf("w = %d x = %d y = %d z = %d \n" , w,x,y,z); to
} A) 62.799999 B) 6.28 C) 12.56 D) 0
C Language FAQ’s Page 6 of 22

Ans: A int x;
90. What is the output of the following program? x = ++++a;
void main() printf("%d %d", a,b);
{ }
printf("nn \n\n nn\n"); Ans: Compiletime error
printf("nn /n/n nn/n"); 97. What is the output of the following code?
} void main()
Ans: {
nn int a = 97;
printf("%d %u %o %x %c", a,a,a,a,a);
nn }
nn /n/n nn/n Ans: 97 97 141 61 a
98. What is the output of the following code?
91. What is the output of the following code? void main()
void main() {
{ int i = 4;
int x; printf("%d" , i++ * i++);
x=10; printf("%d " , ++i * ++i);
x*=x+5; }
printf("%d" , x); Ans: 20 56
} 99. What is the output of the following code?
Ans: 150 void main()
92. What is the output of the following code? {
void main() printf("%d %d %d", 5<<1, 5>>1, ~5);
{ }
int x; Ans: 10 2 -6
x=5; 100. What is the output of the following code?
x++ * ++x; void main()
printf("%d", x); {
} int var = 5;
Ans: 7 printf("%d" , var++ * var++);
93. What is the output of the following program? }
void main() Ans: 30
{ 101. What is the output of the following code?
float a=5, b = 2; void main()
int c,d; {
c = a % b; printf("%d %d %d" , 5 | 2 , 5 & 2, 5 ^ 2);
d = a / 2; }
printf("%d \n" , d); Ans: 7 0 7
} 102. What is the output of the following code?
Ans: Compiletime error void main()
94. What is the output of the following program? {
void main() int var = 5;
{ printf("%f" , var);
int a,b; }
a = -3 - -25; Ans: Runtime Error [Floating point not linked]
b = -3 - -(-3); 103. What is the output of the following code?
printf("a= %d b = %d \n" , a,b); void main()
} {
Ans: a = 22 b = -6 int var1 = 4, var2 = 6;
95. What is the output of the following program? var2 = var1++ && printf("Computer");
void main() printf("%d %d" , var1, var2);
{ }
int i = 2, j = 3, k, l; Ans: Computer 5 1
float a,b; 104. What is the output of the following code?
k = i / j * j; void main()
l = j / i * i; {
a = i / j * j; int x;
b = j / i * i; x = 10 << 16;
printf("%d %d %f %f \n" , k,l , a,b); printf("%d" , x);
} }
Ans: 0 2 0.0 2.0 Ans: 0
96. What is the output of the following code? 105. What is the output of the following code?
void main() void main()
{ {
int a=5; int var1 = 5, var2 = 10;
C Language FAQ’s Page 7 of 22

var1 = var1 &= var2 && 10; 114. What is the output of the following code?
printf("%d %d" , var1, var2); void main()
} {
Ans: 1 10 int var1 = 15, var2 = 10, p, q;
106. What is the output of the following code? p = var1 > 14;
void main() q = var1 > 8 && var2 == 8;
{ printf("p=%d q=%d " ,p,q);
int var = 5; }
printf("%d " , var = ++var == 6); Ans: p = 1 q = 0
} 115. What is the output of the following program?
Ans: 1 void main()
107. What is the output of the following code? {
void main() int p;
{ p = 1;
int x; p = p + 2 * p++;
x = 10 >> 16; printf("%d" , p);
printf("%d" , x); }
} Ans: 4
Ans: 0 116. What is the output of the following code?
108. What would be the output of the following code? void main()
void main() {
{ int var = 1234.5678;
char str[ ] = "computer"; printf("%d" , var);
char *str1 = "computer"; }
printf("%d %d" , sizeof(str), sizeof(str1)); Ans: 1234
} 117. What is the output of the following program?
Ans: 9 2 void main()
109. What is the output of the following code? {
void main() printf("%d " , -10 & 5 );
{ }
unsigned int x = -1; Ans: 4
int y; 118. What is the output of the following program?
printf("%u " , ++x); void main()
printf("%u " , y = -x); {
} short m = 9, n = 0, p = 0;
Ans: 0 0 p+=n+=m;
110. What is the output of the following code? p+=n+=m+=-p;
void main() printf("m=%d n=%d p=%d\n" , m,n,p);
{ }
printf("%d %d " ,sizeof(3.14f), sizeof(3.14)); Ans: m=0 n=9 p=18
} 119. What is the output of the following code?
Ans: 4 8 void main()
111. What is the output of the following program? {
void main() printf("%d " , printf("Computer"));
{ }
int m = 210000; Ans: Computer 8
printf(" m = %d " , m); 120. What is the output of the following program?
} void main()
Ans: 13392 +INF {
112. What is the output of the following program? int ii = 10;
void main() ii <<= 1;
{ printf("%d \n" , ii);
int i = 15, j = 4, m, n; }
m = i > 9; Ans: 20
n = j > 2 && j != 2; 121. What is the output of the following code ?
printf("m = %d n = %d\n" , m, n); void main()
} {
And: m = 1 n = 1 unsigned int ii = -1;
113. What is the output of the following program? printf("%d \n" , ii);
void main() printf("%u \n", ii * -1);
{ }
int x; Ans: -1 1
x = ~0; 122. What is the output of the following program?
printf("%d" , x); void main()
} {
Ans: -1 int i = 2, j = 3, k = 0;
C Language FAQ’s Page 8 of 22

int p; 132. What is the output of the following program?


p = (i , k, j); void main()
printf("%d \n" , p); {
} printf(“%d”,(float)3/2);
Ans: 3 }
123. What it the output of the following program? Ans: 0
void main() 133. What is the output of the following program?
{ void main()
int x; {
x = -~!!~printf(""); float i, j;
printf("%d" , x); scanf("%f %f", &i, &j); /* input values 2.5 3.5 */
} printf("%.2f %.3f", i, j);
Ans: 2 }
124. What is the output of the following program? Ans: 2.50 3.500
void main() 134. What is the output of the following program?
{ void main()
int k; {
printf("%o" , k = (~2 | 3) > ~0 ? 7 : 8<<2); int i, j, k;
} i=10; j=5; k=0;
Ans: 40 k=(++i)>(++j)?(i++):(j++);
125. What is the output of the following program? printf(“%d %d %d”,i, j, k);
void main() }
{ Ans: 12 6 11
printf("%d" , 900 * 90 / 90); 135. What is the output of the following program?
} void main()
Ans: 171 {
126. What is the output of the following program? int y=5;
void main() int z;
{ z = y++ / y++;
printf('%d" , 3 | printf("hi\n") || printf("%s" , HELLO\n")); printf(“%d %d”,z,y);
} }
Ans: hi 1 Ans: 1 7
127. What is the outut of the following code? 136. What is the output of the following program?
void main() void main()
{ {
char ch = 'a'; int x=3, y=4, z=4;
ch = ch - 32; printf("ans=%d",(z>=y>=x? 100 : 200));
printf("%c" , ch); }
} Ans: ans = 200
Ans: ‘A’ 137. What is the output of the following program?
128. What is the output of the program? void main()
void main() {
{ int i=-1,j=-1,k=0,l=2,m;
printf("%d", sizeof(int) ? 1 ? 2 : 3 : 4 ); m=i++ && j++ && k++ | |l++;
} printf("%d %d %d %d %d",i,j,k,l,m);
Ans: 2 }
129. What is the output of the following program? Ans: 0 0 1 3 1
void main() 138. What is the output of the following program?
{ void main()
printf("%d, %d", sizeof('c'), sizeof(100)); {
} int i=5;
Ans: 2 2 printf(“%d”,i=++i ==6);
130. What is the output of the following program? }
void main() Ans: 1
{ 139. What is the output of the following program?
int i = 100; void main()
printf("%d", sizeof(sizeof(i))); {
} int a;
Ans: 2 a = 3+5*5+3;
131. What is the output of the following program? printf("%d",a);
void main() }
{ Ans: 31
int x = 4; 140. What is the output of the following program?
printf("%d",printf("%d%d ",x,x) ); void main()
} {
Ans: 4 4 2 double f = 22.5;
C Language FAQ’s Page 9 of 22

printf("%e",f); float f = (char) 5.23f;


printf("%f",f); printf("%0.2f" , f);
printf("%g",f); }
} Ans: 5.0
Ans: 2.250000e+01 22.500000 22.5 150. What is the output of the following program?
141. What is the output of the following code? void main()
void main() {
{ char a = '\101';
int i=400, j=300 , k = 500; printf ("%c \n",a);
printf("%d %d %d"); }
} Ans: A
Ans: 500 300 400 151. What is the output of the following program?
142. What is the output of the following code? void main()
void main() {
{ int a,b;
printf("\n-Three") + printf("\nfour") * printf("\nfive") - a=b=20;
printf("\nsix"); scanf("%d %d",a,&b);
} printf("entered values are %d %d",a,b);
Ans: Four Five Three Six }
143. What is the output of the following code? Ans: 20 5
void main() 152. What is the output of the following program?
{ void main()
printf("hai")||printf("bye"); {
} int a;
Ans: hai a=100;
144. What is the output of the following code? printf("%d %d",++a,++a);
void main() getch();
{ }
int x, y, z; Ans: 102 101
x = 5; y = 6; z = 7; 153. What is the output of the following program?
z == x <= y; void main()
printf("\n%d",z); {
} int i=-1;
Ans: 7 +i;
145. Which of the following format specifier is used to print printf("i = %d, +i = %d \n",i,+i);
hexadecimal values? }
A. %hx B.%ox C.%x D.%hex Ans: -1 -1
Ans: C 154. Which of the following is not a valid operator?
146. What is the output of the following code? A) + B)++ C)+++ D)+=
void main() Ans: Option C
{ 155. Which of the following daa type cannot be used with
int a=b=1; operator %?
a=a++ + ++b; A) char B)double C)float D) Both B and C
b=b++ + ++a; Ans: Option D
printf("%d %d", a,b); 156. What is the output of the following code?
} void main()
Ans: 5 8 {
147. What is the output of the following code? int x = 10;
void main() const int y = x;
{ x = x + 2;
int n = 12, k; printf("%d %d" , x, y);
printf("%d" , (k = sizeof(n + 12.0)) ++ ); }
} Ans: 12 10
Ans: Error 157. what is the output of the following code?
148. What is the output of the following program? void main()
void main() {
{ int a = 100;
int a = 3, b = 5, c = 1; const int b;
b = ++b && --c || (a = !a); b = a;
a = c || a--; printf("%d %d" , a ,b );
printf("%d %d %d" , a,b,c); }
} Ans: 12 10
Ans: 0 0 0 158. What will be printed by the code given below?
149. What is the output of the following code? void main()
void main() {
{ int value = 5;
C Language FAQ’s Page 10 of 22

printf("%s" , !(value %2) ? "yes" : "no"); 171. What will be the output of the following arithmetic
} expression ?
Ans: no 5+3*2%10-8*6
159. What will be the output of the following program? Ans: -37
void main() 172. What will be the output of the following statement?
{ printf("%i",35,2+8*5%10-2);
int x = 5; Ans: 35
printf("%d %d %d\n", x, x<<2, x>>2); 173. What will be the output of the following statement?
} int a=10;
Ans: 5 20 1 printf("%d &i",a,10);
160. How can a '%' character be printed with printf()? Ans: 10 &i
Ans: printf(“%%”); 174. What will be the output of the following statement?
161. What will be the output of the following program? printf("%X%x%ci%x",11,10,'s',12);
void main() Ans: B a si c
{ 175. Following declarative statement is valid or invalid?
int a = 2, b = 3; long x;
printf("%d" , a+++b); Ans : valid
printf("a=%d , b=%d" , a,b); 176. What will be the output of the following statements?
} int a = 1, b = 2 , c;
Ans: 5 a = 3 b = 3 c = = a = = b;
162. What is the output of the following code? printf("%d",c);
void main() Ans: Garbage value
{ 177. What will be the output of the following program?
char ch = 'A'; void main()
ch = ch + 32; {
printf("%c" , ch); float a = 3.26;
} printf("%f",ceil(a));
Ans: a }
163. What is the output of the following code? Ans: 4.0
void main() 178. What will be the output of the following statements?
{ int a = 5, b = 2, c = 10, i = a>b<c;
char ch = 'A'; printf("%d",i);
ch = ch + 1; Ans: 1
printf("%c", ch); 179. What will be the output of the following program?
} int a = 10;
Ans: ‘B’ void main() {
164. What is the return type of printf() and scanf()? int a = 50;
Ans: int printf("%d",a); }
165. What is the output of the following code? Ans: 50
void main() 180. What will be the output of the following statements?
{ float c = 1.3;
int a ; printf("%d%d",sizeof(c),sizeof(1.3));
printf(“%d” , a); Ans: 4 8
} 181. What will be the output of the following statement?
Ans: Garbage value printf( 3 + "goodbye");
166. What is the output of the following code? Ans: dbye
void main() 182. What will be the output of the following statement?
{ printf("hello""""world");
int a = a + 1; a) error
printf(“%d” , a); b) hello""""world
} c) hello
Ans: Garbage value d) helloworld
167. what is the output of the following code? Ans: option d)
void main() 183. What will be the output of the following statements?
{ int i = 1,j;
int a++; j=i--- -2;
printf(“%d”, a); printf("%d",j);
} Ans: 3
Ans: Compile time error 184. What will be the output of the following statements?
168. What is the range of "real constants" in 'C'? int k = 12;
Ans: 3.4 E -38 to 3.4E+38 k=k--;
169. How many keywords are there in 'C' ? printf("%d",k);
Ans: 32 Ans: 11
170. What will be the output of the following statement ? 185.What will be the output of the following statements?
/* /* printf("hello"); */ */ int a=5,b=6,c=9,d;
Ans: Compile time error d=(a<b?(a>c?1:2):(c>b?6:8));
C Language FAQ’s Page 11 of 22

printf("%d",d); i = 64 / square(4);
Ans: 2 printf("%d" , i);
186. What will be the output of the following program? }
#include<stdio.h> Ans: 64
#include<math.h> 195. What is the output of the following code?
void main() #define a 10
{ int a = fmod(5,3); printf("%d",a); } void main()
Ans: 2 {
187. What will be the output of the following program ? #define a 50
#include<stdio.h> printf("%d",a);
#include<math.h> }
void main() Ans: 50
{ 196. What is the output of the following code?
int n; char *str = "324.89"; #define clrscr() 100
n = atoi(str); printf("%d",n); void main()
} {
Ans : 324 printf("%d\n",clrscr());
188. What will be the output of following program? }
void main() Ans: 100
{ printf("%d"); } 197. What is the output of the following code?
a) error b) no output c) %d d) 0 void main()
Ans: 0 {
189. What will be the output of the following statements? enum colors {BLACK,BLUE,GREEN}
int i = 3; printf("%d%d%d",BLACK,BLUE,GREEN);
printf("%d%d",i,i++); return(1);
Ans: 4 3 }
190. What will be the output of the following program ? Ans: 0 1 2
#include<stdio.h> 198. What is the output of the following code?
void main() void main()
{ {
int a = 36, b = 9; int i=1,j=2;
printf("%d",a>>a/b-2); switch(i)
} {
Ans:9 case 1: printf("GOOD");
191. What will be the output of the following program ? break;
#include<stdio.h> case j: printf("BAD");
int main() break;
{ }
printf("%d" , main); return 0; } }
a) exits with stack overflow Answer: Compiler Error: Constant expression required in function
b) compile error "variable undeclared" main.
c) base address of the function main 199. What is the output of the following code?
d) 0 void main()
Ans: c {
192. Is the relational expression a<b<c legal in C? int i=0;
Ans: yes for( ; i++ ; printf("%d",i) ) ;
printf("%d",i);
193. What is the output of the following code? }
void main() Ans: 1
{ 200. What is the output of the following code.
struct xx void main()
{ {
int x = 3; register int a=2;
char name[ ] = "hello"; printf("Address of a = %d" , &a);
}; printf("Value of a = %d" , a);
struct xx, *s; }
s = &xx; Answer:
printf("%d" , s->x); Compier Error: '&' on register variable
printf("%s" , s->name); Rule to Remember:
} & (address of ) operator cannot be applied on register variables.
Ans: Compile time error 201. What is the output of the following code.
194. What is the output of the following code? void main()
#define square(x) x*x {
void main() float i=1.5;
{ switch(i)
int i; {
C Language FAQ’s Page 12 of 22

case 1: printf("1"); }
case 2: printf("2"); A. y = 20 B. x = 0
default : printf("0"); C. x = 10 D. x = 1
} Ans: Option C
} 206. what is the output of the following program
Answer: Compiler Error: switch expression not integral #include <stdio.h>
202. What is the output of the following program? void main()
void main() {
{ int i = 1;
int i = 4; switch(i)
switch(i) {
{ printf("Hello \n");
default: case 1:
printf("Four\n"); printf("Hi \n");
case 1: break;
printf("One\n"); case 2:
break; printf("Bye \n");
case 2: break;
printf("Two\n"); }
break; }
case 3: A. Hello Hi B. Hello Bye
printf("Three\n"); C. Hi D. Bye
} Ans: Option C
} 207. The EOF is equivalent to
Ans: Four one a. -1 b. 1
203. Point out the error c. 0 d. none of the above
void main() Ans: option a
{ 208. Which of the following can be used across files.
int i = 1; a. extern b. volatile
for( ; ; ) c. static d. const
{
printf("%d \n", i++); Ans: Option a
if(i>10) break; 209. When fopen() fails to open a file it returns
} a. NULL b. -1
} c. 1 d. None of the above
A. There should be a condition in the for loop. Ans: Option a
B. The two semicolons should be dropped. 210. What is the output of the following code.
C. The for loop should be replaced by a while loop. void main()
D. No error. {
Ans: Option D int i=2;
204. point out the error switch(i)
#include <stdio.h> {
void main() case 1: printf("one");
{ case 2: printf("two");
int i = 1; case 3: printf("three");
while() }
{ }
printf("%d \n", i++); Ans: two three
if(i>10) break; 211. What is the output of the following code.
} void main()
} {
A. There should be a condition in the while loop. int i=5, *p, **p1, ***p2;
B. There should be at least a semicolon in the while(). clrscr();
C. The while loop should be replaced by a for loop. p=&i;
D. No error. p1=&p;
Ans: Option A p2=&p1;
205. which of the following is the correct output for the printf("%d",***p2);
program given below. }
#include <stdio.h> Ans: 5
void main() 212. What is the output of the following code.
{ void main()
int x = 10, y = 20; {
if(!(!x)&&x) static int i;
printf("x = %d\n",x); int j;
else clrscr();
printf("y=%d\n",y); printf("%d\n",i);
C Language FAQ’s Page 13 of 22

printf("%d",j); y = myFunc (x);


} printf ("y = %s \n", y);
Ans: 0 garbage value return 0;
213. What is the output of the following code. }
#define square(x) x*x A. y = HELLO
void main() B. y = ELLO
{ C. y = LLO
int i=5; D. y = LO
s=square(5+1); Ans: Option D
printf("%d",s); 221.
} int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
Ans: 11 What value does testarray[2][1][0] in the sample code above
214. What is the output of the following code. contain?
void main() 222. What is the output of the following program?
{ void main()
int a[5]={10,20,30,40,50}; {
int *p1,*p2; int *p;
clrscr(); int a=5;
p1=&a[1]; *p++;
p2=&a[3]; printf("%d",a);
printf("%d",p2-p1); return 0;
} }
Ans: 4 Ans: 5
215. The function calls itself is called ? 223.
Ans: Recursion #define MAX_NUM 15
216. The value of an automatic variable that is declared but Referring to the sample above, what is MAX_NUM?
not initialized will be? Ans: Macro
a. 0 b.-1 224. what is not a c-storage class?
c. garbage d. none of these A.auto B.extern C.register D.stack
Ans: Option C Ans: D
217. enum day = { jan = 1 ,feb=4, april, may} 225. What is the output of the following code?
what is the value of may? char *array[4]={"abcdefgh"}
a)4 b)5 c)6 d)11 e)none of the above printf("%d",&array[4]-(array));
Ans: Option C Ans: 4
218. What is the output of the program 226. What is the output of the following code.
int fn(int x); #define sq(a) (a*a)
void main() printf ("%d",sq (3+2));
{ Ans: 11
int f; 227. What is the output of the following code.
clrscr(); #define max 20
f=fn(5); printf ("%d", ++max);
printf("%d",f); Ans: Compile time error
} 228. What is importance of free() function?
int fn(int x) Ans: It deal locates dynamic memory allocation
{ 229. What is a macro?
if(x<=0) Ans: Substitution text or replacement text defined by #define
return 0; 230. What is the output of the following program?
else void main()
return(fn(x-1) + x); {
} int a[ ] = {23,45,67};
Ans: 15 int *p;
219. With every use of a memory allocation function, what p = a;
function should be used to release allocated memory which printf("\n%d",*p);
is no longer needed? p++;
A. unalloc() B. dealloc() C. release() D. free() printf("\n%d",*p);
Ans: Option D return 0;
220. What is the output of the following code? }
char* myFunc (char *ptr) Ans: 23 45
{ 231. Which of the following 'return' statement is incorrect?
ptr += 3; a.return; b.return(20); c.return(x*y*z);
return (ptr); d.return(1,2,3);
} Ans: Option D
int main() 232. If "a" is an array of 5 x 5 dimension, a[2][4] is same as
{ a. **(a+3+4) b. *(a+3)+*(a+4)
char *x, *y; c. **(a+3)+4 d. *(*(a+2)+4)
x = "HELLO"; Ans: Option D
C Language FAQ’s Page 14 of 22

233. What is the output of the following program? #include<stdio.h>


void main() main()
{ {
char y[10]=”abcedefghi”; if(1)
char *p = y; printf("hello");
p = p + 9; printf("bye");
printf(“%c\n”,*p); }
} Ans: hello bye
a. i b. Program will have runtime error 240. What is the output of the following program?
c. Unpredictable d. No visible output #include<stdio.h>
Ans: i main()
234. What is the output of the following code. {
void main() if(-1)
{ printf("hello");
int y[2][2] = {{1,2}, {3,4}}; printf("bye");
int *p = y[1]; }
p = p + 1; Ans: hello bye
printf(“%d\n”,*p); 241. What is the output of the following program?
} #include<stdio.h>
a. 4 b. 3 main()
c. The program doesnot compile {
d. Output is unpredictable if(0)
Ans: 4 printf("hello");
235.what is the output of the following program? printf("bye");
void main() }
{ Ans: bye
int a[]={23,45,67}; 242. What is the output of the following program?
printf("\n%d",*a); #include<stdio.h>
a++; main()
printf("\n%d",*a); {
return 0; if(0);
} printf("hello");
And: Compile time error printf("bye");
236. What is the Name of the pointer int **p; ? }
a) pointer to pointer b) double pointer Ans: Hello bye
c) float pointer e) integer pointer 243. What is the output of the following program?
#include<stdio.h>
Ans: Option a main()
237.Select one option {
void main() if()
{ printf("hello");
int a[]={23,45,66}; printf("bye");
[a]2 = 5; }
printf("%d",a[2]); Ans: Error
return 0; 244. What is the output of the following program?
} #include<stdio.h>
Compilation error main()
Runtime error {
5 if(1)
None of the above printf("hello");
Ans: Complilation error else
238. what is the output of the following code? printf("bye");
void main() }
{ Ans: hello
int x = 3; 245. What is the output of the following program?
switch(x) #include<stdio.h>
{ main()
case4: printf("Four"); break; {
case3: printf("Three"); break; if(0)
case2: printf("Two");break; printf("hello");
case1: printf("one");break; else
default: printf("Zero");break; printf("bye");
} }
} Ans: bye
Ans: Zero 246. What is the output of the following program?
239. What is the output of the following program? #include<stdio.h>
C Language FAQ’s Page 15 of 22

main() default:
{ printf("hai");
if(-1) }
printf("hello"); Ans: hai
else 254. What is the output of the following program?
printf("bye"); #include<stdio.h>
} main()
Ans: hello {
247. What is the output of the following program? switch(0)
#include<stdio.h> default:
main() printf("hai");
{ }
if(23); Ans: hai
printf("hello"); 255. What is the output of the following program?
else #include<stdio.h>
printf("bye"); main(){
} switch(9.8)
Ans: Compiletime error case 9.8:
248. What is the output of the following program? printf("hai");
#include<stdio.h> }
main() Ans: Error
{ 256. What is the output of the following program?
if(23) #include<stdio.h>
printf("hello"); main()
else; {
printf("bye"); switch(1)
} {
Ans: Hello bye default:
249. What is the output of the following program? printf("hai");
#include<stdio.h> case 0:
main() printf("bye");
{ }
else }
printf("hello"); Ans: hai bye
} 257. What is the output of the following program?
Ans: Error – Misplaced else #include<stdio.h>
250. What is the output of the following program? main()
#include<stdio.h> {
main() switch(1)
{ {
if(printf("hello")); default:
} printf("hai");
Ans: hello break;
251. What is the output of the following program? case 0:
#include<stdio.h> printf("bye");
main() }
{ }
switch(0) Ans: hai
case 0: 258. What is the output of the following program?
printf("hai"); #include<stdio.h>
} main()
Ans: hai {
252. What is the output of the following program? switch(1)
#include<stdio.h> {
main() case 0:
{ printf("bye");
switch(1) default:
case 0: printf("hai");
printf("hai"); }
} }
Ans: blank output Ans: hai
253. What is the output of the following program?
#include<stdio.h> 259. What is the output of the following program?
main() #include<stdio.h>
{ main()
switch(1) {
C Language FAQ’s Page 16 of 22

switch(1) 264. What is the output of the following code?


{ #include<stdio.h>
case 0: main()
printf("bye"); {
break; if(printf("%c",59))
default: {
printf("hai");
} }
} return 0;
Ans: hai }
Ans: ;
260. What is the output of the following program?
#include<stdio.h> 265. What is the output of the following code?
main(){ #include<stdio.h>
switch(1){ main()
case 1: {
printf("bye"); while(printf("%c",65)){}
default: return 0;
printf("hai"); }
} Ans: Infinet loop
} 266. What is the output of the following code?
Ans: Bye hai #include<stdio.h>
261. What is the output of the following program? main()
#include<stdio.h> {
main() while()
{ printf("hello");
switch(1) return 0;
{ }
case 1: Ans: Compiletime error
printf("bye"); 267. What is the output of the following code?
break; #include<stdio.h>
default: main()
printf("hai"); {
} while("hai");
} printf("hello");
Ans: bye return 0;
262. What is the output of the following program? }
#include<stdio.h> Ans: Infinet loop
main() 268. What is the output of the following code?
{ #include<stdio.h>
int a='b'; main()
switch(a) {
{ for(;;)
case 'a': printf("hello");
printf("a"); return 0;
break; }
case 'b': Ans: infinet loop
printf("b");
} 269. What is the output of the following code?
} #include<stdio.h>
Ans : b main()
263. What is the output of the following program? {
#include<stdio.h> if("true")
main() printf("true");
{ else
char a='b'; printf("false");
switch(a) return 0;
{ }
case 'a': Ans: true
printf("a"); 270. What is the output of the following code?
break; #include<stdio.h>
case 'b': main(){
printf("b"); if("false")
} printf("true");
} else
Ans: b printf("false");
C Language FAQ’s Page 17 of 22

return 0; L1:printf("%d ",a);


} a--;
Ans: true if(a>1) goto L1;
return 0;
271. What is the output of the following code? }
#include<stdio.h> Ans: 3 2
main() 277. What is the output of the following code?
{ #include<stdio.h>
if(1) main()
printf("true"); {
else; L1:int a=3;
printf("false"); printf("%d",a);
return 0; a--;
} if(a>1) goto L1;
Ans: true false return 0;
272. What is the output of the following code? }
#include<stdio.h> Ans: Compiletime error
main()
{ 278. What is the output of the following code?
if(0xcafebabe) #include<stdio.h>
printf("true"); main()
else {
printf("false"); int i=0;
return 0; for(;i;)
} printf("\nFor Loop");
Ans: true printf("\nEnd");
273. What is the output of the following code? return 0;
#include<stdio.h> }
main() Ans: end
{
int a=0; 279. What is the output of the following code?
do #include<stdio.h>
printf("Start"); main()
while(a); {
printf("end"); int i=0;
return 0; while(i)
} printf("\nWhile Loop");
Ans: NareshIT end printf("\nEnd");
274. What is the output of the following code? return 0;
#include<stdio.h> }
main() Ans: end
{ 280. What is the output of the following code?
float a=0.7; #include<stdio.h>
if(a==0.7) main()
printf("true"); {
else int i=0;
printf("false"); do
return 0; printf("\nDoWhile Loop");
} while(i);
Ans: false printf("\nEnd");
275. What is the output of the following code? return 0;
#include<stdio.h> }
main() Ans: DiWhile Loop
{ End
int a=2; 281. What is the out put of the following program
else if(a>1) printf("hai"); int main()
else if(a>2) printf("bye"); {
return 0; int i;
} for(;scanf("%d",&i); printf("%d",i));
Ans: Compiletimer error [misplaced else] return 0;
}
276. What is the output of the following code? Ans: loop repeats for infinite times because the result of scanf will
#include<stdio.h> be non zero it is in condition part
main() 282. What is the output?
{ int main()
int a=3; {
C Language FAQ’s Page 18 of 22

int i=5; return 0;


while (i-- >0) printf("%d",i); }
i=5; Ans: 2 1 to 11 10
printf("\n"); 288. Write the output for the following?
while (i-- >0) printf("%d",i); int main()
printf("\n"); {
while (i-- >0) printf("%d",i); int x=1;
printf("\n"); do while(x<=10)
return 0; {
} x++;
Ans: 43210 } while(x<=5);
43210 printf("%d",x);
283. What is the output? return 0;
int main() }
{ Ans: x=11
int i=0; 289. Write the output
for (;i<5;i++) void main()
{ {
printf("%d",i); int a;
} a=1;
return 0; while(a-->=1)
} while(a-->=0)
Ans: 5 printf("%d",a);
284. What is the output? }
int main() Ans: -1
{ 290. Write the output?
char j=1; int main()
while (j<=255) {
{ unsigned int res;
printf("%d",j); res=(64>>(2+1-2))&(~(1<<2));
j=j+1; printf("%d",res);
} getch();
printf("\n"); return 0;
} }
Ans: infinite Ans: 32
285. What is the output of the following program? 291. What is the output of the following program?
int main() #include <stdio.h>
{ void main()
int x=1,y=1; {
for(; y; printf("%d%d\n",x,y); int i = 0;
y = x++ <= 5; for( ; i<=9; )
return 0; {
} i++;
Ans: printf("Value is : %d\n" , i);
21 }
31 }
41 Ans: 1 to 10
51 292. What is the output of the following program?
61 #include <stdio.h>
70 void main()
286. How many times printf is executed {
int main() int i,j;
{ for(i=0,j=0; i<5,j<25; i++,j++) ;
int x; printf("i=%d j=%d",i,j);
for (x= -1; x<=10; x++) }
{ Ans: I = 25 j = 25
printf("hello"); 293. What is the output of the following program?
} #include <stdio.h>
} void main()
Ans: 12 times {
287. What is the value of i int var = - 10;
int main() for( ; var ; printf("%d\n",var++));
{ }
int i=1,j=0; Ans: -10 to -1
while(j<=9) 294. What is the output of the following program?
printf("%d%d",++i,++j); #include <stdio.h>
C Language FAQ’s Page 19 of 22

void main() }
{ Ans: 100 0
int var1 = 10; 300. What is the output of the following program?
int var2 = 6; #include <stdio.h>
if(var1 = 5) void main()
var2++; {
printf("%d %d\n",var1,var2++); unsigned int num = 65000;
}
Ans: 5 7 while(num++ != 0) ;
295. What is the output of the following program? printf("%d",num);
#include <stdio.h> }
void main() Ans: 1
{ 301. What is the output of the following code?
int var = 0; void main()
for( ; var++; printf("%d",var)); {
printf("%d",var); int a = -3;
}
Ans: 1
clrscr();
296. What is the output of the following program? a=-a-a+!a;
#include <stdio.h> printf("%d\n",a);
void main() }
{ Ans: 6
int var1 = 0; 302. What is the output of the following code?
int var2 = 20; void main()
char num1 = 1; {
char num2 = 10; int x,y,z,k=10;
if(var1,var2,num1,num2);
k+=(x=5,y=x+2,z=x+y);
printf("Computer"); printf("%d %d %d %d",x,y,z,k);
} }
Ans: Computer Ans: 5 7 12 22
297. What is the output of the following program? 303. What is the output of the following code?
#include <stdio.h> void main()
void main() {
{ int a=5,b=6;
while(1) printf("%d ",a=b);
{
if(printf("%d",printf("%d")))
printf("%d ",a==b);
break; printf("%d %d ",a,b);
else }
continue; Ans: 6 1 6 6
}
} 304. What is the output of the following code?
Ans: 0 1 #define MSSG "Hello World\n"
298. What is the output of the following program? void main()
#include <stdio.h> {
void main()
{
printf(MSSG);
unsigned int var = 10; }
Ans: Hello World
while(var-- >= 0)
printf("%u",var); 305. What is the output of the following code?
} void main()
Ans: Infinite loop {
299. What is the output of the following program? int a=9;
#include <stdio.h> clrscr();
void main()
{
if(a=5)
int var1, var2=2,num=100,a; printf("It is important to be nice");
else
clrscr(); printf("It is nice to be important");
}
if(var1=var2%2) Ans: It is important to be nice
num=2; 306. What is the output of the following code?
a=2; void main()
printf("%d %d",num,var1);
C Language FAQ’s Page 20 of 22

{ printf(“%d\n”,*p);
int a=20,b=3; }
if(a<10) a. 4 b. 3
a=a-5; c. The program doesnot compile
b=b+5; d. Output is unpredictable
printf("%d %d\n",a,b); Ans: 4
} 312. what is the output of the following program?
Ans: 20 8 void main()
307. What is the output of the following code? {
void main() int a[]={23,45,67};
{ printf("\n%d",*a);
int a=9,b=0,c=0; a++;
if(!a<10&&!b||c) printf("\n%d",*a);
printf("Difficulties make us better"); return 0;
else }
printf("Difficulties make us bitter"); And: Compile time error
}
Ans: Difficulties make us better 313. What is the output of the following program?
308. What is the output of the following code? #include<stdio.h>
void main() void main()
{ {
int i=1,j=9; if()
if(i>=5&&j<5) printf("hello");
i=j+2; printf("bye");
printf("%d",i); }
} Ans: Error
Ans: 1 314. What is the output of the following program?
309. What is the output of the following code? #include<stdio.h>
void main() void main()
{ {
int a=0,b=0; if(23);
clrscr(); printf("hello");
if(!a) else
{ printf("bye");
b=!a; }
if(b) Ans: Compile time error
a=!b; 315. What is the output of the following program?
} #include<stdio.h>
printf("%d %d",a,b); void main()
} {
Ans: 0 1 if(23)
310. What is the output of the following program? printf("hello");
void main() else;
{ printf("bye");
char y[10]=”abcedefghi”; }
char *p = y; Ans: Hello bye
p = p + 9; 316. What is the output of the following program?
printf(“%c\n”,*p); #include<stdio.h>
} void main()
a. i b. Program will have runtime error {
c. Unpredictable d. No visible output if(printf("hello"));
Ans: i }
Ans: hello
311. What is the output of the following code. 317. What is the output of the following program?
void main() void main()
{ {
int y[2][2] = {{1,2}, {3,4}}; int a[5]={2,3};
int *p = y[1]; printf(“%d%d%d”,a[2],a[3],a[4]);
p = p + 1; }
C Language FAQ’s Page 21 of 22

Ans: 0 0 0 for(; ;)
printf("welcome");
318. What is the output of the following program? }
#define x 1+2 Ans: infinite loop
void main() 326. What is the output of the following program?
{ void main()
printf(“%d %d”,x/x, x*3); {
} for(;0 ;)
Ans: 5 7 printf("welcome");
319. What is the output of the following program? printf(“Hello”);
void main() }
{ Ans: Hello
int x=-5>>1;
printf(“%d”,x); 327. What is the output of the following program?
} void main()
Ans: -3 {
320. What is the output of the following program? int a[]={500,300,30,20,60};
void main() printf(“%d”,(a+1)[2]);
{ }
int arr[]={1,2,3,4,5,6,7,8,9,10}; Ans: 20
int i; 328. What is the output of the following program?
for(i=0;i<10;i++) void main()
arr[arr[i]]=arr[i]; {
printf(“%d”,arr[3]); if(0?1:2)
} printf("Hello");
Ans: 3 else
321. What is the output of the following code? printf("Durga soft");
void main() }
{ Ans: Hello
int a = 11; 329. What is the output of the following program?
printf("%d%o%x",a,a,a); void main()
} {
Ans: 11 13 b char str1[]=”Hello”;
322. What is the output of the following code? char stt2[]=”abc”;
void main() str1=str2;
{ puts(str);
int a = 98; }
char ch='c'; Ans: compile time error
clrscr(); 330. What is the output of the following program?
printf("%c %d",a,ch); int i;
} void main()
Ans: b 99 {
printf("i=%d",i);
323. What is the output of the following program? }
int array[4][4] ={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; Ans: 0
for (i=2;i<0;i--) 331. What is the output of the following program?
for (j=2;j<=0;j--) void main()
printf("%d", arr[i][j]); {
Ans: null output / nothing is printed char str[]=”abcdef”;
324. What is the output of the following program? ++str;
void main() ++*str;
{ puts(str);
int a[]={5,3,3,2,6}; }
printf(“%d\t%d”,sizeof(a+1),sizeof(a)); Ans: Compiletime error
} 332. What is the output of the following program?
Ans: 2 10 void main()
325. What is the output of the following program? {
void main() char str[40]=”abcdef0123456”;
{ strrev(str+4);
C Language FAQ’s Page 22 of 22

puts(str);
} }
Ans: abcd6543210fe return 0;
333. What is the output of the following program? }
#define A 15; Ans: ;
void main()
{ 340. What is the output of the following code?
int x; void main()
x=++A; {
printf(“%d %d”,x,A); float f = 66.6;
} printf("%c" , (char) f);
Ans: compiletime error }
334. What is the output of the following program? Ans: B
void main() 341. What is the output of the following program?
{ void main()
int arr[2]={20,40}; {
*arr=10; int a = 7.2;
*(arr+1)=30; printf(“%d”,a);
printf(“%d %d”,arr[0],1[arr]); }
}
335. What is the output of the following program? 342. What is the output of the following program?
void main() void main()
{ {
int arr[3][3]={ 10,20,30}; int i = 5;
printf(“\n %d”,sizeof(arr[1]); printf("%f", i);
printf(“\n %d”,sizeof(arr[1][0]); }
}
343. What is the output of the following program?
336. What is the output of the following program? void main()
void main() {
{ if(0xabc)
int x[4]; printf("Hello");
int I; else
for(I=0;I<10;I++) printf("Wipro");
a[I]=I*I; }
printf(“%d %d”,a[3],a[4]);
} 344. What is the output of the following program?
337. What is the output of the following program?
#define TEST(a) a<0 ? –a:-a; void main()
void main() {
{ int a[2] = {2, 5, 8, 1};
int x=5; printf("%d", *(arr+2));
clrscr(); }
printf(“%d\t%d”,TEST(+x),TEST(-x));
} 345. What is the output of the following program?
338. What is the output of the following program? void main()
const int MAX = 15; {
void main() int x[2] = {5, 10};
{ x[2]= 20;
enum e{a, b, MAX}; x[3]= 30;
printf("%d %d %d", a, b, MAX); printf("%d",*(arr+3));
} }

339. What is the output of the following code?


#include<stdio.h>
main()
{
if(printf("%c",59))
{

You might also like