Vous êtes sur la page 1sur 7

Sample Questions 1

1.
Which of the following is invalid variable name
a)
b)
c)
d)

__1
1__
c__
__c

2.
What is the output of the following:
printf(%d,printf(%d,100));
3.
What is the output of the following:
printf(%d,32768);
4.
Which of the following is invalid C constant
a)
b)
c)
d)

123.45
0001
0x12.45
0xbc40

5.
Which of the following is a valid C constant
a)
b)
c)
d)

.001
0xfga;
1.2e-0.2
0x1.45

6.
What is the output of the following:
printf(%d %d, 72,072);
a)
b)
c)
d)

72
72
72
72

72
58
072
90

7.
What is the output of the following:
printf(%d %d, 0x72,0X72);
a)
b)
c)
d)

72 72
72 114
114 114
72 90

8.
What is the output of the following:
char a=a\0;
printf(%d,sizeof(a));
9.
What is the output of the following:
printf(%d %d ,sizeof(7.0),sizeof(7.0L));
a)
b)
c)
d)

8
4
8
4

8
4
10
8

10.
What is the output of the following:
printf(%e,12.5);
a)
b)
c)
d)

12.5
1.250000e+01
12.5000
syntax error

11.
What is the output of the following:
printf(%.3f,12.34532);
a)
b)
c)
d)

.345
.3456
12.345
12.3456

12.
What is the output of the following:
printf(%c,65+1);
a)
b)
c)
d)

A
B
65
66

13.
What is the output of the following:
main()
{
int a,b;
a=-3 - -3;
b=-3 - -(-3);
printf(a=%d b=%d,a,b);
}
14.
What is the output of the following:
main()
{
int x;
x=3*4%5;
printf(x=%d,x);
}
15.
What is the output of the following:
main()
{
int x;
x=3+4-7*8/5%10;
printf(x=%d,x);
}

16.
What is the output of the following:
main()
{
int x;
x=4%5+6%5;
printf(x=%d,x);
}
17.
What is the output of the following:
main()
{
int x;
x=-3*-4% -6/ -5;
printf(x=%d,x);
}
18.
What is the output of the following:
main()
{
int x;
x=3**4-7^8;
printf(x=%d,x);
}
19.
What is the output of the following:
main()
{
int a=5.99999;
int b=5.00001;
printf(a=%d b=%d,a,b);
}
20.
What is the output of the following:
main()
{
float a;
a=4/2;
printf(%f %f , a,4/2);
}

21.
What is the output of the following:
int a=0;
printf(%d %d %d , a++,++a,a);
printf(%d,a);
22.
What is the output of the following:
int a=10,b=++a,c=++b;
printf(%d,b);
23.
What is the output of the following:
int a=0,b,c;
b=--a,c=a++;
printf(%d %d %d ,a,b,c);
24.
What is the output of the following:
int x=10,y=5,p,q;
p=x>9;
q=x>3 && y!=3;
printf(%d %d,p,q);
25.
What is the output of the following:
int a=100,b=100,c;
c=(a==100 || b>200);
printf(%d,c);
26.
What is the output of the following:
int x=3,y=4,z=4;
printf(%d,(z>=y>=x?100:200));
27.
What is the output of the following:
int x=3,y=4,z=4;
printf(%d, z>=y && y>=x ?1:0);

28.
What is the output of the following:
int x=-4,y,z=10;
y=x%-3;
y=(y?0:z*z);
printf(%d,y);
29.
What is the output of the following:
int x=3,y,z;
z=y=x;
z=y+=x=-z
printf(%d %d %d ,x,y,z);
30.
What is the output of the following:
int c=0,d=5,e=10,a;
a=c>1 ? d>1 || e>1 ? 100:200:300;
printf(%d,a);
31.
What is the output of the following:
int x=10,y=20;
x=!x;
y=!x && !y;
printf(%d %d,x,y);
32.
What is the output of the following:
int x=10,y;
y=x>>2<<1;
33.
What is the output of the following:
printf(%d,11^5);
34.
What is the output of the following:
int x=3,z;
z=x++ + ++x;
printf(%d %d ,x,z);

35.
What is the output of the following:
int x=3,z;
z=x++ + x++;
printf(%d %d ,x,z);
36.
What is the output of the following:
int x=3,z;
z=++x * ++x * ++x;
printf(%d ,z);
37.
What is the output of the following:
int x=3,y=3,z=3;
z-=-x-- - --y;
printf(%d %d %d ,x,y,z);
38.
What is the output of the following:
int x,y,z;
x=y=z=1;
z=++x && ++y && ++z;
printf(%d %d %d ,x,y,z);
39.
What is the output of the following:
int x=10,y;
y=--x--;
printf(%d %d ,x,y);
40.
What is the output of the following:
main()
{
main();
}