250+ TOP MCQs on Precedence and Order of Evaluation and Answers

C helps anyone preparing for VMware and other companies C interviews. One should practice these Objective Questions and answers continuously for 2-3 months to clear VMware interviews on C Programming language.

Here is a listing of online C test questions on “Precedence and Order of Evaluation” along with answers, explanations and/or solutions:

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

  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 2, y = 2;
  5.         float f = y + x /= x / y;
  6.         printf("%d %fn", x, f);
  7.         return 0;
  8.     }

a) 2 4.000000
b) Compile time error
c) 2 3.500000
d) Undefined behaviour
Answer: b
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 1, y = 2;
  5.         if (x && y == 1)
  6.             printf("truen");
  7.         else
  8.             printf("falsen");
  9.     }

a) true
b) false
c) compile time error
d) undefined behaviour
Answer: b
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 1, y = 2;
  5.         int z = x & y == 2;
  6.         printf("%dn", z);
  7.     }

a) 0
b) 1
c) Compile time error
d) Undefined behaviour
Answer: b
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 3, y = 2;
  5.         int z = x /= y %= 2;
  6.         printf("%dn", z);
  7.     }

a) 1
b) Compile time error
c) Floating point exception
d) Segmentation fault
Answer: c
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 3, y = 2;
  5.         int z = x << 1 > 5;
  6.         printf("%dn", z);
  7.     }

a) 1
b) 0
c) 3
d) Compile time error
Answer: a
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 3; //, y = 2;
  5.         const int *p = &x;
  6.         *p++;
  7.         printf("%dn", *p);
  8.     }

a) Increment of read-only location compile error
b) 4
c) Some garbage value
d) Undefined behaviour
Answer: c
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 2, y = 2;
  5.         int z = x ^ y & 1;
  6.         printf("%dn", z);
  7.     }

a) 1
b) 2
c) 0
d) 1 or 2
Answer: b
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 2, y = 0;
  5.         int z = x && y = 1;
  6.         printf("%dn", z);
  7.     }

a) 0
b) 1
c) Compile time error
d) 2
Answer: c
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 0, y = 2;
  5.         if (!x && y)
  6.             printf("truen");
  7.         else
  8.             printf("falsen");
  9.     }

a) True
b) False
c) Compile time error
d) Undefined behaviour
Answer: a
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 0, y = 2;
  5.         int z = ~x & y;
  6.         printf("%dn", z);
  7.     }

a) -1
b) 2
c) 0
d) Compile time error
Answer: b
Clarification: None.

  250+ TOP MCQs on General Utilities and Answers

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top