C-MCQs set-5


Q.1 How many times the below loop will be executed?


    int main()
{
    int x, y;
    for(x=5;x>=1;x--)
 {
    for(y=1;y<=x;y++)
      printf("%d\n",y);
 } 

}


Options:
a) 15 b) 11 c) 10 d) 13



Q2. Is there any difference int the following declarations?

  
   int fun(int arr[]);
   int fun(int arr[2]);



Options:
a) Yes b) No



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


    void main()
{
    int x = 1, y = 0, z = 5;
    int a = x && y || z++;
    printf("%d", z);

}


Options
a) 6 b) 5 c) 0 d) varies



Q4. What will be the final value of j in the following C code?


    int main()
{
    int i = 10, j = 0;
    if (i || (j = i + 10))
    //do something ;

}

Options
a) 0 b) 20 c) Compile time error d) Depends on language standard



Q5. What will be the output ?

   
     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) 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 output?



    int main()
{
    int i = 0;
    int j = i++ + i;
    printf("%d\n", j);

}

Options
a) 0 b) 1 c) 2 d) Compile time error



Q8. What will be the output ?



    int main()
{
    int c = 2 ^ 3;
    printf("%d\n", c);

}


Options
a) 1 b) 8 c) 9 d) 0



Q9. What will be the output ?

  
    int main()
{
    int x = 2, y = 1;
    x *= x + y;
    printf("%d\n", x);
    return 0;

}


Options:
a) 5 b) 6 c) Undefined Behaviour d) Compile time error



Q10. What will be the output ?


    int main()
{
    int a = 1, b = 2;
    a += b -= a;
    printf("%d %d", a, b);

}


Options
a) 1 1 b) 1 2 c) 2 1 d) 2 2