Here is a listing of C programming Objective 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?
-
#include
-
void main()
-
{
-
int b = 5 - 4 + 2 * 5;
-
printf("%d", b);
-
}
a) 25
b) -5
c) 11
d) 16
Answer: c
Clarification: None.
2. What will be the output of the following C code?
-
#include
-
void main()
-
{
-
int b = 5 & 4 & 6;
-
printf("%d", b);
-
}
a) 5
b) 6
c) 3
d) 4
Answer: d
Clarification: None.
3. What will be the output of the following C code?
-
#include
-
void main()
-
{
-
int b = 5 & 4 | 6;
-
printf("%d", b);
-
}
a) 6
b) 4
c) 1
d) 0
Answer: a
Clarification: None.
4. What will be the output of the following C code?
-
#include
-
void main()
-
{
-
int b = 5 + 7 * 4 - 9 * (3, 2);
-
printf("%d", b);
-
}
a) 6
b) 15
c) 13
d) 21
Answer: b
Clarification: None.
5. What will be the output of the following C code?
-
#include
-
void main()
-
{
-
int h = 8;
-
int b = (h++, h++);
-
printf("%d%dn", b, h);
-
}
a) 10 10
b) 10 9
c) 9 10
d) 8 10
Answer: c
Clarification: None.
6. What will be the output of the following C code?
-
#include
-
void main()
-
{
-
int h = 8;
-
int b = h++ + h++ + h++;
-
printf("%dn", h);
-
}
a) 9
b) 10
c) 12
d) 11
Answer: d
Clarification: None.
7. What will be the output of the following C code?
-
#include
-
void main()
-
{
-
int h = 8;
-
int b = 4 * 6 + 3 * 4 < 3 ? 4 : 3;
-
printf("%dn", b);
-
}
a) 3
b) 33
c) 34
d) Run time error
Answer: a
Clarification: None.
8. What will be the output of the following C code?
-
#include
-
void main()
-
{
-
int a = 2 + 3 - 4 + 8 - 5 % 4;
-
printf("%dn", a);
-
}
a) 0
b) 8
c) 11
d) 9
Answer: b
Clarification: None.
9. What will be the output of the following C code?
-
#include
-
void main()
-
{
-
char a = '0';
-
char b = 'm';
-
int c = a && b || '1';
-
printf("%dn", c);
-
}
a) 0
b) a
c) 1
d) m
Answer: c
Clarification: None.
10. What will be the output of the following C code?
-
#include
-
void main()
-
{
-
char a = 'A';
-
char b = 'B';
-
int c = a + b % 3 - 3 * 2;
-
printf("%dn", c);
-
}
a) 65
b) 58
c) 64
d) 59
Answer: d
Clarification: None.