Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

C Questions & Answers
#1

1) int p=5,r;

r=(p--)+(++p)+p+(p++)+(--p);

printf(?%d?,r);

a)27 b)25 c)23 d)none




2) int a=5,b=6,p=9;

if(p=a+b,a++,p=a-b) printf("P");

else printf("R"); This code makes

a)P b)R c)no output d)Complier Error




3) int i=5,j=6;

-i;

printf(?%d %d?,i,-j); This code makes output

a)-5 -6 b)-5 6 c)5 -6 d)5 6




4) float f; int p=5,r=2;

f=p/r The value of f is___________



5) #define x(y) y*y

main()

{ int r,p=5;

r=x(p)/x(p);

printf("%d",r); } This code makes

a)25 b)36 c)49 d)1




6) if(printf(?\0?)) printf("P");

else printf("R"); This code makes

a)P b)R c)no output d)Complier Error




7) int i=-544;

printf("%u",i); This code makes output

a)544 b)-64992 c)64992 d)-544




8) #define int char

#define char float

main()

{ printf("%d %d %d",sizeof(char),sizeof(int),sizeof(float));

} This code makes

a)Complier Error b)1 2 4 c)1 1 1 d)4 4 4




9) (i) for(i=1;i>0;i++) {}

(ii) for(i=1;;i++) {}

a)(i) finite loop (ii) infinite loop

b)(i) infinite loop (ii) infinite loop

c)(i) finite loop (ii) finite loop

d)(i) infinite loop (ii) Complier Error




10) union u

{ struct s

{ int i;

float f; }s1;

Char c[5]; }u1;

The total no. of bytes require for the ?union u1? is______bytes




11) int r,p; char c=?5?,d[3]=?5?;

r=c-?0?; p=d-?0?;

if(r==p) printf(?P?);

else printf(?R?); This code makes

a)R b)P c)Cann?t define d)Compiler Error




12) float *f,e=4.56;

f=&e; printf(?%d?,sizeof(f)); The output is _________




13) int p=44;

do while(p<44) printf("P");

while(p>44); printf("R"): This code makes

a)PR b)PPP.... c)R d)Compiler Error




14) int k=1,j=-1,l=2,p,r;

p=--k||++j&&l--; r=++j&&++p||++k;

printf("%d %d %d %d %d",j,k,l,p,r);

The output of above code is________________




15) int p=56,r;

r=~p;

printf(?%d?,r); This code makes

a)-56 b)-55 c)-57 d)-44




16) for(i=0;i<5;printf(?R?),i++);

printf(?P?); This code makes

a)RRRRRP b)RPRPRPRPRP c)PPPPPR d)Compiler Error




17) i=5;

j=++i++;

printf(?%d %d?,i,j); This code makes

a)6 6 b)7 6 c)7 7 d)Compiler Error




18) (1/0)?((0/0)?printf("P"):printf("R")):printf("S"); This code makes

a)P b)R c)S d)Compiler Error




19) main()

{

printf(?%d?,printf(?%d\t%d?,printf(?xyz\rabc\t?),44));

} This code makes output

a)xyz\rabc\t 10 444 b)xyzabc 6 444 c)abc 8 444 d)xyz 8 444




20) int p,r;

P=4,456;

r=5,544+p;

printf(?d% %d?,p,r); This code makes

a)4,456 5,000 b)4,456 10,000 c)4 5 d)Compiler Error;




21) #define x 50

#define y x+10

main()

{

int p,r;

p=y*2;

r=44/y;

printf(?%d%d?,p,r);

} The values of p & r are ____________




22) 1. #define p 66

2. main()

3. { int r=2;

4. p=p+r;

5. printf(?%c?,p); } This code makes

a)Compiler Error at line 4 b)Compiler Error at line 5

c)Compiler Error at line 3 d)Output is D




23) double far *f, near *n;

printf(?%d %d?,sizeof(f),sizeof(n)); This code makes output

a)2 2 b)4 2 c)8 4 d)4 4




24) for(p=8;p>0;printf(?%d ?,p--))

{

switch(p)

{

case 5:

case 6:

p=0;

break;

}

} This code makes output

a)8 7 0 0 4 3 2 1 b)8 7 6 5 c)8 7 6 d)8 7 0




25) main() s() f()

{ { {

void (*f)(),s(); printf(?sss?); printf(?fff?);

f=s; } }

f();

} This code makes

a)sss b)fff c)a or b d)Complier Error




26) int p[10]={5,6},r;

r=p[p[p[p[1]]]];

printf(?%d?,r); This code makes

a)6 b)garbage value c)0 d) Compiler Error




27) main()

{

int p=0;

while(p<=50)

for(;Wink

if(++p%50==0)

break;

printf(?%d?,p);

} This code makes

a)50 b)100 c)150 d)Compiler Error




28) float *p,a[]={5.4,5.6,5.8};

p=&a;

p++;

printf(?%f?,*p); This code makes output

a)5.5 b)6.4 c)5.7 d)5.6




29) main() g(int l)

{ {

int i=5,k=5,j; return(--l);

g(); }

j=g(i++)+(k--)+g(k);

printf(?%d?,j);

} This code makes output

a)15 b)14 c)13 d)12




30) int i=4,j=5,k=6;

j=(i+k,k++,j+--k),(k-i,--i+j);

printf("%d %d %d",i,j,k); The output of this code is _____________



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

b
b
c
2.0
a
b
c
d
a
6
b
2
c
1 0 2 1 1
c

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

a
d
b
c
c
70 10
a
b
d
a
c
b
d
c
3 11 6
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)