345 FAQS With Ans
345 FAQS With Ans
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
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
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
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
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));
} }