11. 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
 main()
{
    char string[]="Hello World";
	display(string);
}
 
void display(char *string)
{
	printf("%s",string);
}

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

Monday, September 5th, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
 main()
{
	  printf("%x",-1<<4);
}

9. 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()
{
	int i=3;
	switch(i)
	{
	    default:printf("zero");
	    case 1: printf("one");
			break;
		case 2:printf("two");
			break;
		case 3: printf("three");
			break;
	 }  
}

8. 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()
{
	char *p;
	printf("%d %d ",sizeof(*p),sizeof(p));
}

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

Friday, September 2nd, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
 main()
{
	int i=-1,j=-1,k=0,l=2,m;
	m=i++&&j++&&k++||l++;
	printf("%d %d %d %d %d",i,j,k,l,m);
}

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

Friday, September 2nd, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
 main()
{
	extern int i;
	i=20;
	printf("%d",i);
}

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

Friday, September 2nd, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
9
10
11
12
13
 main()
{
	int c[ ]={2.8,3.4,4,6.7,5};
	int j,*p=c,*q=c;
	for(j=0;j<5;j++){
		printf(" %d ",*c);
		++q;	  
	}
	for(j=0;j<5;j++){
		printf(" %d ",*p);
		++p;
	}
}

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

Friday, September 2nd, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
9
 main()
{
	float me = 1.1;
	double you = 1.1;
	if(me==you)
		printf("I love U");
	else
		printf("I hate U");
}

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

Friday, September 2nd, 2011  »  Posted By  »  Total 0 Comment
1
2
3
4
5
6
7
8
9
 main()
{
	float me = 1.1;
	double you = 1.1;
	if(me==you)
		printf("I love U");
	else
		printf("I hate U");
}
Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: