C-MCQs set-4


Q1. Which of the following is NOT a valid storage class in C language?


  a) Extern
  b) Dynamic
  c) Register
  d) Auto




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


  int X=40;
  int main()
{
  int X=20;
  printf(“%d\n”, X);
  return 0;
}



Options:
a) 20 b) 40 c) Error d) No output



Q3. What does y in the sample code evaluated to ?


    int x[] = { 1, 4, 8, 5, 1, 4 }; 
    int *ptr, y; 
    ptr  = x +  4; 
    y = ptr - x;
 


Options
a) -3 b) 4 c) 4 + Size of (int) d) 0



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


    void main()
{
    int x = 0;
    if (x = 0)
      printf("Its zero\n");
    else
      printf("Its not zero\n");
}



Options
a) its not zero b) its zero c) Run time error d) None of the above



Q5. What will be the output ?


    int main()
{
    char ch;
    if(ch = printf(""))
        printf("It matters\n");
    else
        printf("It doesn't matters\n");
    return 0;
}



Options
a) It matters b) It doesn't matters c) Run time error d) Nothing



Q6. What will be the output ?

  
    void main ()
{
    int a=2;
    if(a==2)
  {
      a=~a+2<<1;
      printf("%d",a);
  }
    else
  {
        a=~a;
  }
}



Options
a) 6 b) -2 c) 0 d) None of the above



Q7. Given the following program fragment

 
  main ()
{
  int i, j, k;
  i = 3;
  j =2*(i++);
  k =2*(++i);
}



Which one of the given option is correct ?
a) j = 6, k = 10. b) j = 5, k = 6. c) j = 6, k = 8. d) j = 4, k = 6.



Q.8 In the given below code, what will be return by the function get ()?

 
    int get();
    int main()
{
   const int x = get();
   printf("%d", x);
   return 0;
}
   int get()
   {
    return 40;
}


Options
a) 40 b) 20 c) 0 d) Error



Q.9 What value gets printed by the program below?


{
   int w = 3;
   int x = 31;
   int y = 10;
   double z =  x / y % w;
   printf("%f\n", z);
 }


Options:
a) 0 b) 1 c) 3 d) Undefined



Q10. what is the value of x when the following sample code is executed ?

  
   int x = 3; 
    if( x == 2 );
      x = 0; 
    if( x == 3 )
      x++; 
    else x += 2;



Options
a) 4 b) 2 c) 0 d) 3