This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Precedence and Order of Evaluation – 5”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. Which of the following operators has an associativity from Right to Left?
2. Which operators of the following have same precedence?
P. "!=", Q. "+=", R. "<<="
a) P and Q
b) Q and R
c) P and R
d) P, Q and R
3. Comment on the following statement.
n = 1; printf("%d, %dn", 3*n, n++);
a) Output will be 3, 2
b) Output will be 3, 1
c) Output will be 6, 1
d) Output is compiler dependent
4. Which of the following option is the correct representation of the following C statement?
e = a * b + c / d * f;
a) e = (a * (b +(c /(d * f))));
b) e = ((a * b) + (c / (d * f)));
c) e = ((a * b) + ((c / d)* f));
d) e = (a * (b +((c / d) * f)));
Explanation: By using operator precedence and associativity rule. Also, verified by running e = 5 * 4 + 6 / 3 * 2; and printing the final value.
5. While swapping 2 numbers what precautions to be taken care?
b = (b / a); a = a * b; b = a / b;
a) Data type should be either of short, int and long
b) Data type should be either of float and double
c) All data types are accepted except for (char *)
d) This code doesn’t swap 2 numbers
6. What will be the output of the following C code?
int a = 1, b = 2, c = 3, d = 4, e;
e = c + d = b * a;
printf("%d, %d\n", e, d);
a) 7, 4
b) 7, 2
c) 5, 2
d) Syntax error
7. Which of the following is the correct order of evaluation for the given expression?
a = w % x / y * z;
a) % / * =
b) / * % =
c) = % * /
d) * % / =
8. Which function in the following expression will be called first?
a = func3(6) - func2(4, 5) / func1(1, 2, 3);
d) Cannot be predicted
9. Which of the following operator has the highest precedence in the following?
10. Which of the following is a ternary operator?
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Practice Computer Science MCQs
- Watch Advanced C Programming Videos
- Apply for C Internship
- Apply for Computer Science Internship
- Practice BCA MCQs