52. Predict the output or error(s) of the following c code

Monday, September 5th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
 main()
{
	static char *s[ ]  = {“black”, “white”, “yellow”, “violet”};
	char **ptr[ ] = {s+3, s+2, s+1, s}, ***p;
	p = ptr;
	**++p;
	printf(%s”,*--*++p + 3);
}

51. Predict the output or error(s) of the following c code

Monday, September 5th, 2011  »  Posted By  »  Total 1 Comment
1
2
3
4
5
6
7
8
9
10
11
12
 main()
{
	void *vp;
	char ch = ‘g’, *cp = “goofy”;
	int j = 20;
	vp = &ch;
	printf(%c”, *(char *)vp);
	vp = &j;
	printf(%d”,*(int *)vp);
	vp = cp;
	printf(%s”,(char *)vp + 3);
}

50. Predict the output or error(s) of the following c code

Monday, September 5th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
 main()
{
	char  *q;
	int  j;
	for (j=0; j<3; j++) scanf(%s” ,(q+j));
	for (j=0; j<3; j++) printf(%c” ,*(q+j));
	for (j=0; j<3; j++) printf(%s” ,(q+j));
}

49. Predict the output or error(s) of the following c code

Monday, September 5th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 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); 
}

48. Predict the output or error(s) of the following c code

Monday, September 5th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 main()
{
  int a[ ] = {10,20,30,40,50},j,*p;
  for(j=0; j<5; j++)
    {
printf(%d” ,*a); 
a++;
    }
    p = a;
   for(j=0; j<5; j++) 
      {
printf(%d ” ,*p); 
p++;
      }
 }

47. Predict the output or error(s) of the following c code

Monday, September 5th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
 main()
{
	int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
	printf(%u %u %u %d \n”,a,*a,**a,***a);
	printf(%u %u %u %d \n”,a+1,*a+1,**a+1,***a+1);
}

46. Predict the output or error(s) of the following c code

Monday, September 5th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
 main()
{
	show();
}
void show()
{
	printf("I'm the greatest");
}

45. Predict the output or error(s) of the following c code

Monday, September 5th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
 main()
{
	extern out;
	printf("%d", out);
}
int out=100;

44. Predict the output or error(s) of the following c code

Monday, September 5th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
 main()
{
	printf("%d", out);
}
int out=100;

43. Predict the output or error(s) of the following c code

Monday, September 5th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
 main()
{
	extern int i;
	i=20;
	printf("%d",sizeof(i));
}
Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: