Wednesday, 2 March 2016

MCQ - C language

Give your answer with explaination:
 
1) What will be output if you will compile and execute the following c code?


#define x 5+2
void main(){
    int i;
    i=x*x*x;
    printf("%d",i);
}

2) What will be output if you will compile and execute the following c code?

void main(){
char c=125;
    c=c+10;
    printf("%d",c);
}

3) What will be output if you will compile and execute the following c code?

void main(){
   float a=5.2;
  if(a==5.2)
     printf("Equal");
  else if(a<5.2)
     printf("Less than");
  else
     printf("Greater than");
}

4) What will be output if you will compile and execute the following c code?


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

5)What will be output if you will compile and execute the following c code?


void main(){
  int a=10;
  printf("%d %d %d",a,a++,++a);
}
6)What will be output if you will compile and execute the following c code?


void main(){
   char *str="Hello world";
   printf("%d",printf("%s",str));
}
7) What will be output if you will compile and execute the following c code?


#define call(x,y) x##y
void main(){
int x=5,y=10,xy=20;
printf("%d",xy+call(x,y));
}
8) What will be output if you will compile and execute the following c code?


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




No comments:

Post a Comment