# C Operators and Expression-1

###### 1. Which of the following operators takes only integer operands?

a) +

b) *

c) /

d) %

Answer: **D**

Two integers are taken to be input.

###### 2. In an expression involving || operator, evaluation

I. Will be stopped if one of its components evaluates to false

II. Will be stopped if one of its components evaluates to false

III. Takes place from right to left

IV. Takes place from left to right

a) I and II

b) I and III

c) II and III

d) II and IV

Answer: **D**

No explanation is given for this question.

###### 3. Operator % in C Language is called?

a) Percentage Operator

b) Quotient Operator

c) Modulus

d) Division

Answer: **C**

Operator % is called Modulus or Modular or Modulo Division operator in C. It gives the reminder of the division.

int a = 11%4;

Now a holds only 3 which is the reminder.

###### 4. Output of an arithmetic expression with integers and real numbers is ___ by default?

a) Integer

b) Real number

c) Depends on the numbers used in the expression

d) None of the above

Answer: **B**

Any arithmetic operation with both integers and real numbers yield output as Real number only.

5 + 10.56 = 15.560000 which is a real number.

5 + 10.0 = 15.000000 is also a real number.

###### 5. What is the value of a?

`int a = 10 + 4.867;`

a) a = 10

b) a = 14.867

c) a = 14

d) compiler error

Answer: **C**

a is an `int` variable. So 10+4.867 = 14.867 is truncated to 14 and assigned to a.

###### 6. What is the value of a?

`int a = 3.5 + 4.5;`

a) a = 0

b) a = 7

c) a = 8

d) a = 8.0

Answer: **C**

3.5 + 4.5 = 8.0 is a real number. So it is converted to downgraded to `int` value. So a = 8.

###### 7. What is the value of x?

`float x = 3.5 + 4.5;`

a) x = 8.0

b) x = 8

c) x = 7

d) x = 0.0

Answer: **A**

A float variable can hold a real number.

###### 8. If both numerator and denominator of a division operation in C language are integers, then we get

a) Expected algebraic real value

b) Unexpected integer value

c) Compiler error

d) None of the above

Answer: **B**

int a = 5/2 stores only 2.

###### 9. Can you use C Modulo Division operator % with float and int?

a) Only int variables

b) Only float variables

c) int or float combination

d) Numerator int variable, Denominator any variable

Answer: **A**

Modulo Division operator `%` in C language can be used only with integer variables or constants.

###### 10. Associativity of C Operators *, /, %, +, - and = is

a) Operators *, / and % have Left to Right Associativity. Operators + and - have Left to Right Associativity. Operator = has Right to Left Associativity.

B) Operators *, / and % have Right to Left Associativity. Operators + and - have Left to Right Associativity. Operator = has Right to Left Associativity.

C) Operators *, / and % have Right to Left Associativity. Operators + and - have Right to Left Associativity. Operator = has Right to Left Associativity.

D) Operators *, / and % have Right to Left Associativity. Operators + and - have Right to Left Associativity. Operator = has Left to Right Associativity.

Answer: **A**

Operators *, / and % have Left to Right Associativity. Operators + and - have Left to Right Associativity. Operator = has Right to Left Associativitiy.