ThePrismSolutions

ThePrismSolutions

Practice(TEST 2)

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

#include<stdio.h>	
main()
{
	int i=3;
	switch(i)
	 {
	    default:printf("zero");
	    case 1: printf("one");
		   break;
	   case 2:printf("two");
		  break;
	  case 3: printf("three");
		  break;
	  }  
}




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

#include<stdio.h>	
main()
{
	  printf("%x",-1<<4);
}




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

 main()
{
    char string[]="Hello World";
	display(string);
}
void display(char *string)
{
	printf("%s",string);
}




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

main()
{
	int c=- -2;
	printf("c=%d",c);
}




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

	
#define int char
main()
{
	int i=65;
	printf("sizeof(i)=%d",sizeof(i));
}





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

#include<stdio.h>	
main()
{
int i=10;
i=!i>14;
Printf ("i=%d",i);
}





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

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




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

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




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

main()
{
struct xx
{
int x;
struct yy
{
char s;
	struct xx *p;
};
struct yy *q;
};
}




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

#include<stdio.h>	
main()
{
	printf("\nab");
	printf("\bsi");
	printf("\rha");
}