Home / C Programming / Operators and Expressions :: Operators and Expressions

### C Programming :: Operators and Expressions

1. Which of the following operator takes only integer operands?

2.  A.  + B.  * C.  / D.  % E.  None of these

3. 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

4.  A.  I and II B.  I and III C.  II and III D.  II and IV E.  III and IV

5. 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);}
6.  A.  1 1 2 3 B.  1 1 2 2 C.  0 1 2 2 D.  0 1 2 3 E.  None of these

7. Determine output:

void main(){      int c = - -2;       printf("c=%d", c); }
8.  A.  1 B.  -2 C.  2 D.  Error

9. Determine output:

void main(){       int i=10;       i = !i>14;       printf("i=%d", i); }
10.  A.  10 B.  14 C.  0 D.  1 E.  None of these

11. In C programming language, which of the following type of operators have the highest precedence

12.  A.  Relational operators B.  Equality operators C.  Logical operators D.  Arithmetic operators

13. 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);}
14.  A.  c=3 d=3 B.  c=3 d=5 C.  c=5 d=3 D.  c=5 d=5

15. Which of the following comments about the ++ operator are correct?

16.  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

17. What will be the output of this program on an implementation where int occupies 2 bytes?

#include <stdio.h>void main(){      int i = 3;      int j;      j = sizeof(++i + ++i);      printf("i=%d j=%d", i, j);}
18.  A.  i=4 j=2 B.  i=3 j=2 C.  i=5 j=2 D.  the behavior is undefined

19. Which operator has the lowest priority?

20.  A.  ++ B.  % C.  + D.  || E.  &&