ThePrismSolutions

ThePrismSolutions

Practice(TEST 5)

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

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




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

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




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

main()
{
 extern int i;
 i=20;
 printf("%d",sizeof(i));
}




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

main()
{
printf("%d", out);
}
int out=100;




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

	
main()
{
 extern out;
 printf("%d", out);
}
 int out=100;




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

#include<stdio.h>	
main()
{
 show();
}
void show()
{
 printf("I'm the greatest");
}




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 ?

main( )
{
  int a[ ] = {10,20,30,40,50},j,*p;
  for(j=0; j<5; j++)
    {
printf(ā€œ%dā€ ,*a); 
a++;
    }
    p = a;
   for(j=0; j<5; j++) 
      {
printf(ā€œ%d ā€ ,*p); 
p++;
      }
 }




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()
{
 int i=400,j=300;
 printf("%d..%d");
}