Wednesday, October 15, 2008

What is the output?

void main()
{
int a=10,b=20;
char x=1,y=0;
if(a,b,x,y)
{
printf("EXAM");
}
}

a) XAM is printed
b) EXAM is printed
c) Compiler Error
d) Nothing is printed

Monday, October 13, 2008

What will be the o/p of the below program

float i=5, j;

j = ++i/--i/--i*i;

printf(“%f\n”, j);

Choice

a) 0.75
b) 1.25
c) 1.2
d) 0.075
e) 1.000000


Sunday, October 12, 2008

What is the output of following programme ?

int i = 4;
switch (i)
{
default:
;
case 3:
i += 5;
if ( i == 8)
{
i++;
if (i == 9) break;
i *= 2;
}
i -= 4;
break;
case 8:
i += 5;
break;
}
printf("i = %d\n", i);

Choice a: i = 5
Choice b: i = 8
Choice c: i = 9
Choice d: i = 10
Choice e: i = 18

Monday, October 6, 2008

What will be printed when the sample code below is executed?

char *buffer = "0123456789";
char *ptr = buffer;
ptr += 5;
printf( "%s\n", ptr );
printf( "%s\n", buffer );

Choice a: 0123456789
56789
Choice b: 5123456789
5123456789
Choice c: 56789
56789
Choice d: 0123456789
0123456789
Choice e: 56789
0123456789

Friday, October 3, 2008

Identify errors in this below program, if any. Otherwise give the O/p

void main()
{
float a=1.1;
int x=1;
for(a=1.0; a<3.0; a++) {
switch(x)
{
default:
printf("its default\n");
case 1 :
printf("its 1\n");
x++;
continue;
case (1+1) :
printf("its 2\n");
break;
}
}
}