C Programming Questions and Answers – Precedence and Order of Evaluation – 6
C Programming Questions and Answers – Precedence and Order of Evaluation – 6
1. Which of the following are unary operators?
a) sizeof
b) –
c) ++
d) All of the mentioned
View Answer
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 macro definition
d) None of the mentioned
View Answer
3. Associativity of an operator are:
a) Right to Left
b) Left to Right
c) Random fashion
d) Both (a) and (b)
View Answer
4. Which of the following method are 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
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
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
7. Which of the following operators has the lowest precedence?
a) !=
b) &&
c) ?:
d) ,
View Answer
8. Comment on the output of this C code?
#include <stdio.h>
int main()
{
int x = 3, i = 0;
do {
x = x++;
i++;
} while (i != 3);
printf(“%d\n”, x);
}
a) Undefined behaviour
b) Output will be 3
c) Output will be 6
d) Output will be 5
View Answer
#include <stdio.h>
int main()
{
int a = -1, b = 4, c = 1, d;
d = ++a && ++b || ++c;
printf(“%d, %d, %d, %d\n”, a, b, c, d);
return 0;
}
a) 0, 4, 2, 1
b) 0, 5, 2, 1
c) -1, 4, 1, 1
d) 0, 5, 1, 0
View Answer
10. What is the output of this C code?
#include <stdio.h>
int main()
{
int p = 10, q = 20, r;
if (r = p = 5 || q > 20)
printf(“%d”, r);
else
printf(“No Output\n”);
}
a) 1
b) 10
c) 20
d) No Output
View Answer
For more Visit the Link:
Computer Science MCQ All Topic C programming MCQ All Topic