Sunday, January 10, 2010

What string does ptr point to in the sample code below?

char *ptr;
char myString[] = "abcdefg";
ptr = myString;
ptr += 5;

a) fg
b) efg
c) defg
d) cdefg
e) None of the above

What value will x contain when the sample code below is executed?

int x = 3;
if( x == 2 );
x = 0;
if( x == 3 )
x++;
else x += 2;

a) 1
b) 2
c) 3
d) 4
e) 5

Tuesday, December 15, 2009

Ternary Operator

What is the output.

int main()
{
int i=10,j=20;
j = i, j?(i,j)?i:j:j;
printf("%d %d",i,j);
}
Choice:
a)10 10
b)20 20
c)10 11
d)11 10
e)10 20

Monday, June 8, 2009

What is the output of following programme ?

main()
{
int a=2,*f1,*f2;
f1=f2=&a;
*f2+=*f2+=a+=2.5;
*f1+=*f1+=a+=2.5;
printf("\n%d %d %d",a,*f1,*f2);
}

Choice
a) 18,18,18
b) 10,10,10
c) 72,72,72
d) 64,64,64
e) 26,26,26

Monday, June 1, 2009

Whatz the output

void main()
{
int i = abc(10);
printf("%d\n",--i);
}

int abc(int i)
{
return(i++);
}

Choice
a) 10
b) 11
c) 9
d) 0