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

Sunday, October 9th, 2011  »  Posted By  »  Total 6 Comments
1
2
3
4
5
6
7
 main()
{
	int i =0;j=0;
	if(i && j++)
		printf("%d..%d",i++,j);
	printf("%d..%d,i,j);
}

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

Sunday, October 9th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
9
#include "stdio.h"
main()
{
	FILE *ptr;
	char i;
	ptr=fopen("zzz.c","r");
	while((i=fgetch(ptr))!=EOF)
		printf("%c",i);
}

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

Sunday, October 9th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "stdio.h"
aaa() {
	printf("hi");
}
 
bbb(){
	printf("hello");
}
 
ccc(){
	printf("bye");
}
 
main()
{
	int (*ptr[3])();
	ptr[0]=aaa;
	ptr[1]=bbb;
	ptr[2]=ccc;
	ptr[2]();
}

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

Sunday, October 9th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
9
#include "stdio.h"
int one_d[]={1,2,3};
main()
{
	int *ptr; 
	ptr=one_d;
	ptr+=3;
	printf("%d",*ptr);
}

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

Sunday, October 9th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
9
10
11
main(int argc, char **argv)
{
	printf("enter the character");
	getchar();
	sum(argv[1],argv[2]);
}
sum(num1,num2)
int num1,num2;
{
	return num1+num2;
}

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

Thursday, September 15th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
9
10
11
12
13
 main()
{
	char c=' ',x,convert(z);
	getc(c);
	if((c>='a') && (c<='z'))
	x=convert(c);
	printf("%c",x);
}
 
convert(z)
{
	return z-32;
}

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

Thursday, September 15th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
9
10
11
 main()
{
	char *p;
	int *q;
	long *r;
	p=q=r=0;
	p++;
	q++;
	r++;
	printf("%p...%p...%p",p,q,r);
}

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

Thursday, September 15th, 2011  »  Posted By  »  Total 1 Comment
1
2
3
4
5
6
7
8
9
10
 main()
{
	int i=_l_abc(10);
 	printf("%d\n",--i);
}
 
int _l_abc(int i)
{
	return(i++);
}

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

Thursday, September 15th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
9
10
11
12
struct point
{
	int x;
	int y;
};
struct point origin,*pp;
main()
{
	pp=&origin;
	printf("origin is(%d%d)\n",(*pp).x,(*pp).y);
	printf("origin is (%d%d)\n",pp->x,pp->y);
}

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

Thursday, September 15th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
struct aaa{
	struct aaa *prev;
	int i;
	struct aaa *next;
};
main()
{
	struct aaa abc,def,ghi,jkl;
	int x=100;
	abc.i=0;abc.prev=&jkl;
	abc.next=&def;
	def.i=1;def.prev=&abc;def.next=&ghi;
	ghi.i=2;ghi.prev=&def;
	ghi.next=&jkl;
	jkl.i=3;jkl.prev=&ghi;jkl.next=&abc;
	x=abc.next->next->prev->next->i;
	printf("%d",x);
}
Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: