ThePrismSolutions

ThePrismSolutions

Practice(TEST 6)

1. What is the output of the below c code?

#include<stdio.h>	
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);
}




2. How would you insert pre-written code into a current program ?

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);
}





3. Predict the output or error(s) for the following ?

main()
{
char *p="hai friends",*p1;
p1=p;
while(*p!='\0') ++*p++;
printf("%s   %s",p,p1);
}





4. Predict the output or error(s) for the following ? ?

main()
int i,j;
	for(i=0;i<=10;i++)
{
	j+=5;
	assert(i<5);
}




5. Predict the output or error(s) for the following ?

	
main()
{
	int i=-1;
	+i;
	printf("i = %d, +i = %d \n",i,+i);
}




6. Predict the output or error(s) for the following ?

#include<stdio.h>	
main()
{
	main();
}




7. Predict the output or error(s) for the following ?

main()
{
	char *cptr,c;
	void *vptr,v;
	c=10;  v=0;
	cptr=&c; vptr=&v;
	printf("%c%v",c,v);
}




8. Predict the output or error(s) for the following ?

main()
{
	char *str1="abcd";
	char str2[]="abcd";
	printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));
}




9. Predict the output or error(s) for the following ?

main()
{
	char not;
	not=!2;
	printf("%d",not);
}




10. Predict the output or error(s) for the following ?

#define FALSE -1
#define TRUE   1
#define NULL   0
main()
{
	   if(NULL)
			puts("NULL");
	   else if(FALSE)
			puts("TRUE");
	   else
			puts("FALSE");
}