Multiple choice technology programming languages

#include int factorial(int n) { (n == 0)? return 1 : return n* factorial(n-1); } int main() { printf("%d",factorial(3)); }

  1. 6

  2. Errror

  3. 1

  4. No output

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

The factorial function has incorrect ternary operator syntax. The code (n == 0)? return 1 : return n* factorial(n-1) is invalid because return statements cannot appear inside a ternary expression in this manner. The correct syntax would be 'return (n == 0) ? 1 : n * factorial(n-1);'. This syntax error causes compilation failure.