Friday, November 25, 2011

Test your C Programming skills Part 3






Q1. Find the o/p:
main() {

   char *p;

   p="Hello";

   printf("%c\n",*&*p);

}
Ans:
     H


Q2. Find the o/p:
main() {

   int i=1;

   while (i<=5){      printf("%d",i);      if (i>2)

     i++;

   }

}

fun() {

   here:

   printf("PP");

}
Ans:


Q3. Find the o/p:
void main() {

   int i=5;

   printf("%d",i++ + ++i);

}

Ans:


Q4. Find the o/p:
main() {

   int i=1,j=2;

   switch(i) {

   case 1: printf("GOOD");

   break;

   case j: printf("BAD");

   break;

   }

}
Ans:



Q5. Find the o/p:
main() {

   int i;

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

}

Ans:


Q6. Find the o/p:
#define f(g,g2) g##g2

main() {

   int var12=100;

   printf("%d",f(var,12));

}
Ans:


Q7. Find the o/p:
main() {

   int i=0;

   for(;i++;printf("%d",i)) ;

}
Ans:


Q8. Find the o/p:
# include < stdio.h >
main() {

   printf("%d", out);

}

int out=100;

Ans:


Q9. Find the o/p:
#include <stdio.h>
main() {

   extern out;

   printf("%d", out);

}

int out=100;

Ans:


Q10. Find the o/p of this:
main( ) {

   int a[ ] = {10,20,30,40,50},j,*p;

   for(j=0; j<5; j++){      printf(“%d” ,*;      a++;    }    p = a;    for(j=0; j<5; j++){      printf(“%d ” ,*p);      p++;    } }



Ans:


Q11. Find the o/p:
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);

}

Ans:


Q12. Find the o/p:
main() {
   int i,j;

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



Ans:


Q13.What are the files which are automatically opened when a C file is executed?

Ans:






No comments:

Post a Comment