42. 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
#include "stdio.h"
main()
{
	struct xx
	{
		int x;
		struct yy
		{
			char s;
			struct xx *p;
		};
		struct yy *q;
	};
}

41. 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
#include "stdio.h"
main()
{
	struct xx
	{
		int x=3;
		char name[]="hello";
	};
	struct xx *s=malloc(sizeof(struct xx));
	printf("%d",s->x);
	printf("%s",s->name);
}

40. 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
#include "stdio.h"
main()
{
	char s[]={'a','b','c','\n','c','\0'};
	char *p,*str,*str1;
	p=&s[3];
	str=p;
	str1=s;
	printf("%d",++*p + ++*str1-32);
}

39. 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 i=0;
	for(;i++;printf("%d",i)) ;
	printf("%d",i);
}

38. 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
#define f(g,g2) g##g2
main()
{
	int var12=100;
	printf("%d",f(var,12));
}

37. 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()
{
	int i;
	printf("%d",scanf("%d",&i));  // value 10 is given as input here
}

36. 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
#include "stdio.h"
main()
{
	int i=1,j=2;
	switch(i)
	{
		case 1:  printf("GOOD");
			break;
		case j:  printf("BAD");
		   break;
	}
}

35. 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
void main()
{
	int i=5;
	printf("%d",i+++++i);
}

34. 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
void main()
{
	int i=5;
	printf("%d",i++ + ++i);
}

33. 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
 main()
{
	static char names[5][20]={"pascal","ada","cobol","fortran","perl"};
	int i;
	char *t;
	t=names[3];
	names[3]=names[4];
	names[4]=t;	
	for (i=0;i<=4;i++)
		printf("%s",names[i]);
}
Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: