PRACTICE QUESTIONS

1.what will be the output of the following C code?

#include<stdio.h>

int main()

{

  int x = 1;

  if(x){

  printf(“all is well\n”);

}

  else

{

  Printf(“I am not a river”);

}

}

1.       Compile time error during compilation

2.       I am well

3.       All is well

4.       I am not a river

2.what will be the output of the following C code?

#include<stdio.h>

void main()

{

  int x = 0;

  if(x++)

  printf(“true\n”);

  elseif(x==1)

  printf(“false”);

}

1.       Undefined behaviour

2.       True

3.       Compile time error

4.       False

3.what will be the output of the following C code?

#include<stdio.h>

void main()

{

  int x = 1;

  if(x>0)

  printf(“insideif\n”);

  elseif(x>0)

  printf(“inside elseif”);

}

         1.    Compile time error

         2.     Insideif Inside elseif

         3.     Inside elseif

         4.     Inside if

4.what will be the output of the following C code?

#include<stdio.h>

void main()

{

  int x = 0;

  if(x==0)

  printf(“true, ”);

  elseif(x=10)

  printf(“false, ”);

  printf(“%d”,x);

}  

1.       True, 10

2.       Compile time error

3.       True, 0

4.       False, 0

5.what will be the output of the following C code?

#include<stdio.h>

void main()

{  

  if(printf(“%d”, printf(“0”)))

  printf(“we are happy”);

  elseif(printf(“1”))

  printf(“we are sad”);

}  

1.       0 we are happy

2.       1 we are sad

3.       Compile time error

4.       1 we are happy