Showing posts with label output. Show all posts
Showing posts with label output. Show all posts

Wednesday, November 30, 2011

C Output Type Question


main( )
{
static int a[ ] = {0,1,2,3,4};
int *p[ ] = {a,a+1,a+2,a+3,a+4};
int **ptr = p;
ptr++;
printf(“\n %d  %d  %d”, ptr-p, *ptr-a, **ptr);
*ptr++;
printf(“\n %d  %d  %d”, ptr-p, *ptr-a, **ptr);
*++ptr;
printf(“\n %d  %d  %d”, ptr-p, *ptr-a, **ptr);
++*ptr;
printf(“\n %d  %d  %d”, ptr-p, *ptr-a, **ptr);
}

Try to find the output !!
This question is seemingly quite unconventional, but try it out without using a compiler, and then compare your results with:


1 1 1
2 2 2
3 3 3
3 4 4

Friday, November 25, 2011

Easy-2

This is second in line with the easy posts.. after a while we shall move onto more tricky ones.. A problem a day keeps the Alzheimer's away.

void main()
{
static int i=i++, j=j++, k=k++;
printf(“i = %d j = %d k = %d”, i, j, k);
}

Guess the output !!