Multiple choice technology programming languages

Find the output of this program. main() { int a[10]; printf("%d",*a+1-*a+3) ; }

  1. Compiler error

  2. 3

  3. -2

  4. 4

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The expression *a+1-*a+3 simplifies to (a[0]+1)-a[0]+3 = 1+3 = 4. The *a terms cancel out, leaving just the constant 4. Option A incorrectly suggests a compiler error - pointer arithmetic on array elements is valid in C.