quiz

Operators in C

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

#include <stdio.h> int main() { char charArray[10]; printf("Size of char array: %d bytes\n", sizeof(charArray)); return 0; }
  • A) 1
  • B) 10
  • C) Compile-time error
  • D) 0
B) 10 Explanation

2. What is the output of the following code?

int x = 5, y = 3; printf("%d\n", x++ + y);
  • A) 8
  • B) 9
  • C) 10
  • D) 7

3. What is the value of x after the following code runs?

#include <stdio.h> int main() { int x = 5; x *= 2 + 3; printf("%d",x); return 0; }
  • A) 25
  • B) 10
  • C) 15
  • D) 13
A) 25 Explanation

4. Which operator in C is used to access the address of a variable?

  • A) *
  • B) &
  • C) ^
  • D) ->

5. What is the result of the following C program?

#include <stdio.h> int main() {int x = 2, y = 10, z = -4;int result = x == z || y > x; printf("Result: %d\n", result); return 0;}
  • A) Result: 0
  • B) Result: 1
  • C) Result: True
  • D) Result: False
B) Result: 1 Explanation

6. How many operands does the ternary conditional operator require in C?

  • A) 1
  • B) 2
  • C) 3
  • D) 4

7. What is the output of the expression 10 << 2 in C?

  • A) 20
  • B) 30
  • C) 40
  • D) 100
C) 40 Explanation

8. What does the ! operator do in C?

  • A) Performs logical OR
  • B) Performs logical AND
  • C) Performs bitwise AND
  • D) Performs logical NOT
D) Performs logical NOT Explanation