Bird
0
0

Which of the following is the correct syntax to return the value 10 inside a while loop in C?

easy📝 Syntax Q3 of 15
C - Loop Control Statements
Which of the following is the correct syntax to return the value 10 inside a while loop in C?
Awhile(condition) { return; 10; }
Bwhile(condition) return 10
Cwhile(condition) { return(10); }
Dwhile(condition) { return 10 }
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax for return with value

    Return statement can be written as return 10; or return(10); both are valid, but return(10); is clearer in this context.
  2. Step 2: Validate loop syntax

    While loop syntax requires braces if multiple statements; here return is a single statement, but braces are allowed.
  3. Final Answer:

    while(condition) { return(10); } -> Option C
  4. Quick Check:

    Correct return syntax inside loop = return(value); [OK]
Quick Trick: Use return(value); inside loops for clarity [OK]
Common Mistakes:
  • Placing return after a semicolon incorrectly
  • Using return without a value when function expects one
  • Misplacing braces around return

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes