C - onditional StatementsWhich of the following is the correct syntax for an if statement in C?Aif (condition) { /* code */ }Bif condition { /* code */ }Cif condition then { /* code */ }Dif [condition] { /* code */ }Check Answer
Step-by-Step SolutionSolution:Step 1: Recall C syntax for if statementsIn C, conditions must be inside parentheses and code inside braces.Step 2: Check each optionif (condition) { /* code */ } matches the correct syntax: if (condition) { /* code */ }.Final Answer:if (condition) { /* code */ } -> Option AQuick Check:Parentheses around condition = correct syntax [OK]Quick Trick: Remember: if (condition) { } in C [OK]Common Mistakes:Omitting parentheses around conditionUsing square brackets instead of parenthesesAdding 'then' keyword which C does not use
Master "onditional 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 6medium C Basics and Execution Environment - Header files and include directive - Quiz 4medium Input and Output - Why input and output are required - Quiz 11easy Input and Output - Using scanf for input - Quiz 4medium Loop Control Statements - Return inside loops - Quiz 12easy Loops - Why loops are needed - Quiz 9hard Operators and Expressions - Relational operators - Quiz 13medium Variables and Data Types - Basic data types - Quiz 4medium Variables and Data Types - Storage size overview - Quiz 14medium Variables and Data Types - Why variables are needed - Quiz 3easy