Multiple choice technology programming languages

3) void main() { int x=10; (x<0) ? (int a = 100) : (int a=1000); printf(“%d”,a); }

  1. 10

  2. 1000

  3. error

  4. none of this

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

The ternary operator attempts to declare variables directly in its branches: (int a = 100) and (int a = 1000). In C, variable declarations are statements, not expressions, and cannot appear inside a ternary operator. The scope issue is also problematic - even if allowed, 'a' would not be visible in the printf statement. This code will not compile and produces an error.