Scroll to Top

Infosys Placement Papers

C Programming Questions and Answers – Arithmetic Operators – 2

Here is a listing of C test questions on “Arithmetic Operators” along with answers, explanations and/or solutions:

1. What will be the output of the following C code?

#include <stdio.h>
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

Answer: d
Explanation: None.

2. What is the precedence of arithmetic operators (from highest to lowest)?
a) %, *, /, +, –
b) %, +, /, *, –
c) +, -, %, *, /
d) %, +, -, *, /

Answer: c
Explanation: None.

4. Which of the following data type will throw an error on modulus operation(%)?
a) char
b) short
c) int
d) float

Answer: d
Explanation: None.

5. Which among the following are the fundamental arithmetic operators, i.e, performing the desired operation can be done using that operator only?
a) +, –
b) +, -, %
c) +, -, *, /
d) +, -, *, /, %

Answer: a
Explanation: None.

6. What will be the output of the following C code?

#include <stdio.h>
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

Answer: a
Explanation: None.

7. What will be the output of the following C code?

#include <stdio.h>
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

Answer: b
Explanation: None.

« Prev – C Programming Questions and Answers – Arithmetic Operators – 1
» Next – C Programming Questions and Answers – Relational & Logical Operators – 1

Related posts

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
%d bloggers like this: