Operators And Expressions(Computer Science > C Program ) Questions and Answers
Question 1. Which of the following operator takes only integer operands?
+
*
/
%
None of these
Explanation:-
Answer: Option D. -> %
Question 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 true III. Takes place from right to left IV. Takes place from left to right
I and II
I and III
II and III
II and IV
III and IV
Explanation:-
Answer: Option D. -> II and IV
Question 3. Determine output: void main() { int i=0, j=1, k=2, m; m = i++ || j++ || k++; printf("%d %d %d %d", m, i, j, k); }
1 1 2 3
1 1 2 2
0 1 2 2
0 1 2 3
None of these
Explanation:-
Answer: Option B. -> 1 1 2 2
Question 4. Determine output: void main() { int c = - -2; printf("c=%d", c); }
1
-2
2
Error
Explanation:-
Answer: Option C. -> 2
Question 5. Determine output: void main() { int i=10; i = !i>14; printf("i=%d", i); }
10
14
0
1
None of these
Explanation:-
Answer: Option C. -> 0
Question 6. In C programming language, which of the following type of operators have the highest precedence
Relational operators
Equality operators
Logical operators
Arithmetic operators
Explanation:-
Answer: Option D. -> Arithmetic operators
Question 7. What will be the output of the following program? void main() { int a, b, c, d; a = 3; b = 5; c = a, b; d = (a, b); printf("c=%d d=%d", c, d); }
c=3 d=3
c=3 d=5
c=5 d=3
c=5 d=5
Explanation:-
Answer: Option B. -> c=3 d=5
Question 8. Which of the following comments about the ++ operator are correct?
It is a unary operator
The operand can come before or after the operator
It cannot be applied to an expression
It associates from the right
All of the above
Explanation:-
Answer: Option E. -> All of the above
Question 9. What will be the output of this program on an implementation where int occupies 2 bytes? #include void main() { int i = 3; int j; j = sizeof(++i + ++i); printf("i=%d j=%d", i, j); }
i=4 j=2
i=3 j=2
i=5 j=2
the behavior is undefined
Explanation:-
Answer: Option B. -> i=3 j=2
Question 10. Which operator has the lowest priority?