Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q6 of 15
C - Operators and Expressions
Find the error in this code snippet:
int a = 5;
int b = 2;
int c = a ** b;
printf("%d", c);
A'**' is not a valid operator in C
BMissing semicolon after variable declaration
CIncorrect printf format specifier
DVariables not initialized
Step-by-Step Solution
Solution:
  1. Step 1: Check operator validity

    In C, '**' is not a valid operator for exponentiation.
  2. Step 2: Identify correct operator usage

    To perform power, a function like pow() from math.h is needed, not '**'.
  3. Final Answer:

    '**' is not a valid operator in C -> Option A
  4. Quick Check:

    Invalid operator '**' = error [OK]
Quick Trick: C has no '**' operator; use pow() for powers [OK]
Common Mistakes:
  • Using '**' for power
  • Forgetting semicolons
  • Wrong printf specifier

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes