Multiple Choice Questions and Answers for Arithmetic Operators in C Language

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?
  1.     #include 
  2.     int main()
  3.     {
  4.         int i = -3;
  5.         int k = i % 2;
  6.         printf("%d\n", k);
  7.     }
a) Compile time error
b) -1
c) 1
d) Implementation defined
Answer:b
2. What is the output of this C code?
  1.     #include 
  2.     int main()
  3.     {
  4.         int i = 3;
  5.         int l = i / -2;
  6.         int k = i % -2;
  7.         printf("%d %d\n", l, k);
  8.         return 0;
  9.     }
a) Compile time error
b) -1 1
c) 1 -1
d) Implementation defined
Answer:b
3. What is the output of this C code?
  1.     #include 
  2.     int main()
  3.     {
  4.         int i = 5;
  5.         i = i / 3;
  6.         printf("%d\n", i);
  7.         return 0;
  8.     }
a) Implementation defined
b) 1
c) 3
d) Compile time error
Answer:b
4. What is the output of this C code?
  1.    #include 
  2.     int main()
  3.     {
  4.         int i = -5;
  5.         i = i / 3;
  6.         printf("%d\n", i);
  7.         return 0;
  8.     }
a) Implementation defined
b) -1
c) -3
d) Compile time error
Answer:b
5. What is the value of x in this C code?
  1.     #include 
  2.     void main()
  3.     {
  4.         int x = 5 * 9 / 3 + 9;
  5.     }
a) 3.75
b) Depends on compiler
c) 24
d) 3
Answer:c
6. What is the output of this C code?
  1.     #include 
  2.     void main()
  3.     {
  4.         int x = 5.3 % 2;
  5.         printf("Value of x is %d", x);
  6.     }
a) Value of x is 2.3
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?
  1.     #include 
  2.     void main()
  3.     {
  4.         int y = 3;
  5.         int x = 5 % 2 * 3 / 2;
  6.         printf("Value of x is %d", x);
  7.     }
a) Value of x is 1
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?
  1.     #include 
  2.     void main()
  3.     {
  4.         int a = 3;
  5.         int b = ++a + a++ + --a;
  6.         printf("Value of b is %d", b);
  7.     }
a) Value of x is 12
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) %, +, -, *, /
Answer:a 
10. Which of the following is not an arithmetic operation?

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
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) +, -, *, /, %
Answer:a 
13. What is the output of this C code?
  1.     #include 
  2.     int main()
  3.     {
  4.         int a = 10;
  5.         double b = 5.6;
  6.         int c;
  7.         c = a + b;
  8.         printf("%d", c);
  9.     }
a) 15
b) 16
c) 15.6
d) 10
Answer:a 
14. What is the output of this C code?
  1.     #include 
  2.     int main()
  3.     {
  4.         int a = 10, b = 5, c = 5;
  5.         int d;
  6.         d = a == (b + c);
  7.         printf("%d", d);
  8.     }
a) Syntax error
b) 1
c) 10
d) 5
Answer: b

Related

Multiple Choice Questions and Answers on Security Data of Cloud Computing for Freshers

1. Which of the following is a compliance standard? a) PCI-DSSb) HIPPAc) GLBAd) All of the mentioned Answer: d Explanation: A compliance standard can be any government regulatory framework. 2....

Multiple Choice Questions and Answers on Security Service Boundary of Cloud Computing for Freshers

1. Which of the following service provider provides the highest level of service ? a) SaaSb) PaaSc) IaaSd) All of the mentioned Answer: a Explanation: As you move upward in the stack, each servic...

Computer Fundamentals Multiple choice Questions and Answers on Binary Multiplication & Division for Freshers

1. Perform binary addition of 1101 + 0010 is ________ a) 1110b) 1111c) 0111d) 1,1101 Answer: b Explanation: The addition is performed as :1101+ 0010_______1111Therefore, the result is 1111. 2. T...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item