Predict The Output
Predict The Output
1)main()
{
printf(“%d%d%d%d”,72,072,0x72,0X72);
}
2) main ()
{
char ch=291;
printf(“%d%d”,32770,ch,);
}
a) –32766,35
b) –32767,45
c) run time error
d) –32766,23
3) main()
{
int x;
X=3+4-7*8/5%10
printf(“x=%d”,X);
}
a) 6
b) run time error since mod produce zero
c) indefinite answer
d) 5
4) main()
{
float a=1.5;
int b=3;
a=b/2+b*8/b-b+a/3;
printf(“a=%f”,a);
}
a) 6.5
b) 7.5
c) 7
d) 5.5
5) main()
{
int a,b;
printf(“Enter values of a and b “);
scanf(“ %d%d “,&a,&b);
printf(“a=%d b=%d”,a,b);
}
a) no output
b) the value of a and b that are inputted
c) run time error
d) compilation error
6) main()
{
printf(“Menu is a list of options you have at a\
particular point in a program. It is just\
like a restaurant menu-everything has a\
misleading name and what you want is never\
available.”);
}
8) main()
{
int I;
for(I=1;I<=9;I++);
printf(“%d”,I);
}
a) compilation error (semicolon not expected)
b) 1,2,3….9
c) 10
d) none of the above(blank screen)
9) main()
{
int a=100,*b,**c,***d;
b=&a;
c=&b;
d=&d;
printf(“%d%d%d%d”, a, *b, **c , ***d);
}
Note: address of a is 4002
address of b is 5006
address of c is 7008
address of d is 7008
a) compilation error (unpredictable value *b **c ***d)
b) 100,4002,5006,7008
c) 100,100,100,100
d) none of the above
10) main()
{
int x=10,y=20;
x=!x;
y=!y;
y=!x&&!y;
a) prì¥Á4G4444¿4444444444444>44
a) 5bjbjŽÙŽÙ555555555555555555 5-655ì³ 5ì³
5>¤555555555555555555555555555555ÿÿ¤555555555ÿÿ¤55555
5555ÿÿ¤55555555555555555
]55555ê5555555ê555ê5555555ê5555555ê5555555ê5555555ê55
5µ55555555555~ 555555~ 555555~ 555555~ 555555~ 55
6ì¥Á6G6 666¿6666666666666>66
7bjbjŽÙŽÙ777777777777777777 7-677ì³ 7ì³
7>¤777777777777777777777777777777ÿÿ¤777777777ÿÿ¤7777777
77ÿÿ¤77777777777777777
]77777ê7777777ê777ê7777777ê7777777ê7777777ê7777777ê777µ
77777777777~ 777777~ 777777~ 777777~ 777777~ 77
8(I=<4)
{
sub[I]=I*I;
printf(“%d\n”,sub[I]);
}
}
}
a) 10,20,40
b) 40
c) no output
d) compilation error
14) main()
{
static int a[]={0,1,2,3,4,};
static int *p[]={a,a+1,a+2,a+3,a+4}
int **ptr;
ptr=p;
**ptr++;
printf(“%d,%d,%d\n”,ptr-p,*ptr-a,**ptr);
*++*ptr;
printf(“%d,%d,%d\n”,ptr-p,*ptr-a,**ptr);
++**ptr;
printf(“%d,%d,%d\n”,ptr-p,*ptr-a,**ptr);
}
a) 1 1 1,1 2 2,1 2 3
b) 1 1 1 ,1 2 3,1 3 3
c) 1 2 2, 1 3 3, 1 3 4
d) compilation error
e) run time error
15) main()
{
static int t[3][2][4]= {
{
2,4,3,6,
1,6,7,9
},
{
8,2,1,1,
2,3,7,3
},
{
1,6,2,4,
0,7,9,5
}
};
printf(“%d%d”,t[2][1][3],*(*(*(t+2)+1)+3));
}