Multiple Choice Questions and Answers for Arithmetic Operators in C Language

https://www.computersprofessor.com/2017/08/multiple-choice-questions-and-answers_31.html
Here is a listing of C test questions on “Arithmetic Operators” along with answers, explanations and/or solutions:
1. What is the output of this C code?
#include
int main()
{
int i = -3;
int k = i % 2;
printf("%d\n", k);
}
a) Compile time error
b) -1
c) 1
d) Implementation defined
b) -1
c) 1
d) Implementation defined
Answer:b
2. What is the output of this C code?
#include
int main()
{
int i = 3;
int l = i / -2;
int k = i % -2;
printf("%d %d\n", l, k);
return 0;
}
a) Compile time error
b) -1 1
c) 1 -1
d) Implementation defined
b) -1 1
c) 1 -1
d) Implementation defined
Answer:b
3. What is the output of this C code?
#include
int main()
{
int i = 5;
i = i / 3;
printf("%d\n", i);
return 0;
}
a) Implementation defined
b) 1
c) 3
d) Compile time error
b) 1
c) 3
d) Compile time error
Answer:b
4. What is the output of this C code?
#include
int main()
{
int i = -5;
i = i / 3;
printf("%d\n", i);
return 0;
}
a) Implementation defined
b) -1
c) -3
d) Compile time error
b) -1
c) -3
d) Compile time error
Answer:b
5. What is the value of x in this C code?
#include
void main()
{
int x = 5 * 9 / 3 + 9;
}
a) 3.75
b) Depends on compiler
c) 24
d) 3
b) Depends on compiler
c) 24
d) 3
Answer:c
6. What is the output of this C code?
#include
void main()
{
int x = 5.3 % 2;
printf("Value of x is %d", x);
}
a) Value of x is 2.3
b) Value of x is 1
c) Value of x is 0.3
d) Compile time error
b) Value of x is 1
c) Value of x is 0.3
d) Compile time error
Answer:d
7. What is the output of this C code?
#include
void main()
{
int y = 3;
int x = 5 % 2 * 3 / 2;
printf("Value of x is %d", x);
}
a) Value of x is 1
b) Value of x is 2
c) Value of x is 3
d) Compile time error
b) Value of x is 2
c) Value of x is 3
d) Compile time error
Answer:a
8. What is the output of this C code?
#include
void main()
{
int a = 3;
int b = ++a + a++ + --a;
printf("Value of b is %d", b);
}
a) Value of x is 12
b) Value of x is 13
c) Value of x is 10
d) Undefined behaviour
b) Value of x is 13
c) Value of x is 10
d) Undefined behaviour
Answer:d
9. The precedence of arithmetic operators is (from highest to lowest)
a) %, *, /, +, –
b) %, +, /, *, –
c) +, -, %, *, /
d) %, +, -, *, /
a) %, *, /, +, –
b) %, +, /, *, –
c) +, -, %, *, /
d) %, +, -, *, /
Answer:a
10. Which of the following is not an arithmetic operation?
a) a *= 10;
b) a /= 10;
c) a != 10;
d) a %= 10;
a) a *= 10;
b) a /= 10;
c) a != 10;
d) a %= 10;
Answer:c
11. Which of the following data type will throw an error on modulus operation(%)?
a) char
b) short
c) int
d) float
a) char
b) short
c) int
d) float
Answer:d
12. Which among the following are the fundamental arithmetic operators, ie, performing the desired operation can be done using that operator only?
a) +, –
b) +, -, %
c) +, -, *, /
d) +, -, *, /, %
a) +, –
b) +, -, %
c) +, -, *, /
d) +, -, *, /, %
Answer:a
13. What is the output of this C code?
#include
int main()
{
int a = 10;
double b = 5.6;
int c;
c = a + b;
printf("%d", c);
}
a) 15
b) 16
c) 15.6
d) 10
b) 16
c) 15.6
d) 10
Answer:a
14. What is the output of this C code?
#include
int main()
{
int a = 10, b = 5, c = 5;
int d;
d = a == (b + c);
printf("%d", d);
}
a) Syntax error
b) 1
c) 10
d) 5
b) 1
c) 10
d) 5
Answer: b