ThePrismSolutions

ThePrismSolutions

Practice(TEST 4)

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

#include<stdio.h>	
main()
{
 char *p;
 p="Hello";
 printf("%c\n",*&*p);
}




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

main()
{
    int i=1;
    while (i<=5)
    {
       printf("%d",i);
       if (i>2)
	  goto here;
       i++;
    }
}
fun()
{
   here:
     printf("PP");
}




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

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




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

void main()
{
	int i=5;
	printf("%d",i++ + ++i);
}




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

	
 void main()
{
	int i=5;
	printf("%d",i+++++i);
}




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

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




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

main()
{
int i;
printf("%d",scanf("%d",&i));  // value 10 is given as input here
}




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

	#define f(g,g2) g##g2
main()
{	
	int var12=100;
	printf("%d",f(var,12));
}




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

main()
{
	int i=0;
 
	for(;i++;printf("%d",i)) ;
	printf("%d",i);
}





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