C-MCQs set-1


Q1. What will be the output ?

  
  {
    float f = 0.1;
    if (f == 0.1)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
  }



Q2. What will be the output of the following C code?

  
    void main()
 { 
    int x = 0, y = 2, z = 3; 
    int a = x & y | z; 
    printf("%d", a);
 }


Options:
a) 3 b) 0 c) 2 d) Run time error



Q3.What will be the output of the following C code?



    void main()
{ 
    int a = 3; 
    int b = ++a + a++ + --a; 
    printf("Value of b is %d", b);
} 


Options
a) Value of x is 12 b) Value of x is 13 c) Value of x is 10 d) Undefined behaviour.



Q4.What will be the output of the following C code?

 
   int main() 
{ 
   int a = 10; 
   double=5.6; 
   int c; 
   c = a + b; 
   printf("%d", c); 
} 


Options
a) 15 b) 16 c) 15.6 d) 10



Q5. What will be the output ?


   int main() 
{ 
   int a = 10, b = 5, c = 5; 
   int d; 
   d = a == (b + c); 
   printf("%d", d);
 } 


Options
a) Syntax error b) 1 c) 10 d) 5



Q6. What will be the output ?

 
   int main() 
{ 
   int i = 3; 
   int l = i / -2; 
   int k = i % -2; 
   printf("%d %d\n", l, k); 
   return 0;
 } 


Options
a) Compile time error b) -1 1 c) 1 -1 d) Implementation defined



Q7. What will be the final value of x in the following C code?


   void main() 
{ 
   int x = 5 * 9 / 3 + 9; 
}


Options
a) 3.75 b) Depends on compiler c) 24 d) 3



Q8. What will be the final value of d in the following C code?

 
   int main() 
{ 
  int a = 10, b = 5, c = 5; 
  int d; 
  d = b + c == a; 
  printf("%d", d); 
} 


Options
a) Syntax error b) 1 c) 5 d) 10



Q9. What will be the output ?

  
   
      void main() 
 { 
      float x =0.1;    
      if (x == 0.1) 
         printf(“Datacode"); 
      else 
         printf("Advanced C Classes"); 
 }  


Options:
a) Advanced C Classes b) Datacode c) Run time error d) Compile time error



Q10. What will be the output ?


   int main() 
{ 
   int a = 10, b = 10; 
   If (a = 5) b--; 
      printf("%d, %d", a, b--); 
} 


Options
a) a = 10, b = 9 b) a = 10, b = 8 c) a = 5, b = 9 d) a = 5, b = 8