C Operators and Expression-2
1. Integer division in a 'C' program results in:
a) Truncation
b) Rounding
c) Underflow
d) None of these
Answer: A
No explanation is given for this question.
2. In a 'C'expression involving || operator, evaluation
a) Will be stopped if one of its components evaluates to false
b) Will be stopped if one of its components evaluates to true
c) Takes place from right to left
d) None of these
Answer: B
No explanation is given for this question.
3. What is the other name of Question Mark Colon Operator?
a) Comparison Operator
b) If-Else Operator
c) Binary Operator
d) Ternary Operator
Answer: D
Question mark operator is also known as Ternary operator.
4. In C programming language, which of the following type of operators have the highest precedence
a) Relational Operators
b) Equality Operators
c) Logical Operators
d) Arithmetic Operators
Answer: D
Arithmetic Operators have the highest precedence in all the operators.
5. Which of the following comments about the ++ operator are correct?
a) It is a unary operator
b) The operand can come before or after the operator
c) It cannot be applied to an expression
d) It associates from the right
e) All of the above
Answer: E
No explanation is given for this question.
6. What number will z in the sample code given below?
int z, x = 5, y = -10, a = 4, b = 2;
z = x++ - --y*b/a;
a) 5
b) 6
c) 9
d) 10
e) 11
Answer: D
According to precedence table execution of the given operators are as follows:
1. x++(Postfix operator) i.e x will become 5
2. y--(Prefix operator) i.e y will become -11
3. * and / have same priority so they will be executed according to their associativity i.e left to right. So, *(Multiplication) will execute first and then /(division).
4. -(Subtraction)
So the complete expression would be
5 - (-11)*2/4 = 5 - (-22)/4 = 5 - (-5) = 5 + 5 = 10.
7. Which operator from the following has the lowest priority?
a) Assignment Operator
b) Division Operator
c) Comma Operator
d) Conditional Operator
e) Unary Operator
Answer: C
No explanation is given for this question.
8. Given b = 110 and c = 20, what is the value of 'a' after execution of the expression a = b = c*=5?
a) 450
b) 10
c) 110
d) -10
e) -110
Answer: B
As the expression is evaluated from right to left.
9. In C programming language, which of the following type of operators have the highest precedence
a) Relational operators
b) Equality operators
c) Logical operators
d) Arithmetic operators
Answer: D
No expression is given for this question.
10. In C programming language, which of the following operator has the highest precedence?
a) Unary +
b) *
c) >=
d) = =
Answer: A
No explanation is given for this question.