C - Loop Control StatementsWhich of the following is the correct syntax to return the value 5 inside a for loop in C?Afor(int i=0; i<3; i++) { return 5; }Bfor(int i=0; i<3; i++) return(5)Cfor(int i=0; i<3; i++) { return; 5; }Dfor(int i=0; i<3; i++) { return 5 }Check Answer
Step-by-Step SolutionSolution:Step 1: Check syntax of return statementReturn must be followed by a value and a semicolon inside braces if used.Step 2: Analyze each optionfor(int i=0; i<3; i++) { return 5; } uses correct syntax with braces and semicolon. for(int i=0; i<3; i++) return(5) misses semicolon, invalid. for(int i=0; i<3; i++) { return; 5; } has return without value then 5; which is invalid. for(int i=0; i<3; i++) { return 5 } misses semicolon after return 5.Final Answer:for(int i=0; i<3; i++) { return 5; } -> Option AQuick Check:Return syntax needs value and semicolon [OK]Quick Trick: Return must have value and semicolon inside braces [OK]Common Mistakes:Omitting semicolon after returnPlacing code after return on same lineUsing return without value in non-void function
Master "Loop Control Statements" in C9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More C Quizzes C Basics and Execution Environment - main function and program entry - Quiz 7medium Conditional Statements - Nested conditional statements - Quiz 6medium Conditional Statements - If–else statement - Quiz 14medium Conditional Statements - If–else statement - Quiz 3easy Input and Output - Why input and output are required - Quiz 2easy Loops - Do–while loop - Quiz 7medium Loops - Why loops are needed - Quiz 5medium Operators and Expressions - Assignment operators - Quiz 8hard Operators and Expressions - Ternary operator - Quiz 6medium Variables and Data Types - Variable declaration and initialization - Quiz 1easy