C Programming Questions and Answers – Precedence and Order of Evaluation – 6

«
»
Sanfoundry’s 1000+ MCQs on C helps anyone preparing for placement in Accenture and other companies. Anyone looking for Accenture placement papers should practice these 1000+ questions continuously for 2-3 months, thereby ensuring a top position in placements.

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

1. Which of the following are unary operators?
a) sizeof
b) –
c) ++
d) all of the mentioned
View Answer

Answer: d
Explanation: None.
advertisement

2. Where in C the order of precedence of operators do not exist?
a) Within conditional statements, if, else
b) Within while, do-while
c) Within a macro definition
d) None of the mentioned
View Answer

Answer: d
Explanation: None.

3. Associativity of an operator is ___________
a) Right to Left
b) Left to Right
c) Random fashion
d) Both Right to Left and Left to Right
View Answer

Answer: d
Explanation: None.
advertisement
advertisement

4. Which of the following method is accepted for assignment?
a) 5 = a = b = c = d;
b) a = b = c = d = 5;
c) a = b = 5 = c = d;
d) None of the mentioned
View Answer

Answer: b
Explanation: None.

5. Which of the following is NOT possible with any 2 operators in C?
a) Different precedence, same associativity
b) Different precedence, different associativity
c) Same precedence, different associativity
d) All of the mentioned
View Answer

Answer: c
Explanation: None.
advertisement

6. Which of the following is possible with any 2 operators in C?
a) Same associativity, different precedence
b) Same associativity, same precedence
c) Different associativity, different precedence
d) All of the mentioned
View Answer

Answer: d
Explanation: None.

7. Which of the following operators has the lowest precedence?
a) !=
b) &&
c) ?:
d) ,
View Answer

Answer: d
Explanation: None.
advertisement

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

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int x = 3, i = 0;
  5.         do {
  6.             x = x++;
  7.             i++;
  8.         } while (i != 3);
  9.         printf("%d\n", x);
  10.     }

a) Undefined behaviour
b) Output will be 3
c) Output will be 6
d) Output will be 5
View Answer

Answer: b
Explanation: None.
advertisement

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

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a = -1, b = 4, c = 1, d;
  5.         d = ++a && ++b || ++c;
  6.         printf("%d, %d, %d, %d\n", a, b, c, d);
  7.         return 0;
  8.     }

a) 0, 4, 2, 1
b) 0, 5, 2, 1
c) -1, 4, 1, 1
d) 0, 5, 1, 0
View Answer

Answer: a
Explanation: None.

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

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int p = 10, q = 20, r;
  5.         if (r = p = 5 || q > 20)
  6.             printf("%d", r);
  7.         else
  8.             printf("No Output\n");
  9.     }

a) 1
b) 10
c) 20
d) No Output
View Answer

Answer: a
Explanation: None.

Sanfoundry Global Education & Learning Series – C Programming Language.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement

Leave a Comment

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter