best conceptual questions in c programming

Best conceptual questions in c programming

  
1. void main()
     {int x=1;
        switch (x)
          { x=x+1;
             case 1 :printf("one");break;
             case 2 :printf("two");break;
             default:printf("three");
          }
      }
What will be output?


Answer: one


2.What  will be output of following code segment

int i=1;
while(i++<);
printf("%d",i);



Answer: 6

3.What is the output of following snippet?

void main()
{int a=321;
 char *p;
p=&a;
printf("%c",*p);
}

Answer: A

Note:The file name must be saved with .c extension.

4.What will be output of following code segment?
#define   x  5+2;
void main()
{ int i;
 i=x*x*x;
printf("%d",i);

Answer: 27

5.What will be output of following code segment?

int x=10;
int =5;
printf("%d",(y,x));

Answer: 10

6.What is the output of following code segment?
int x;
x=++2;
printf("%d",x);
Answer:Error ,because ++ operator does not works on constant .


Comments

Popular posts from this blog

Error http://172.0.0.1:8080/apex application not found in oracle 10g Solved

Sequence diagram of Airport Check-in and Sreening System in uml