C - Input and OutputWrite a C program snippet that reads two integers and prints their sum and product separated by a space. Which code correctly does this?Aint a, b;<br>scanf("%d %d", &a, &b);<br>printf("%d %d", a + b, a * b);Bint a, b;<br>scanf("%d %d", a, b);<br>printf("%d %d", a + b, a * b);Cint a, b;<br>scanf("%d %d", &a, &b);<br>printf("%d %d", a - b, a / b);Dint a, b;<br>scanf("%d %d", &a, &b);<br>printf("%d %d", a * b, a + b);Check Answer
Step-by-Step SolutionSolution:Step 1: Check input reading correctnessscanf must use &a and &b to read two integers correctly.Step 2: Check output matches sum and productprintf should print sum (a + b) first, then product (a * b) separated by space.Final Answer:int a, b; scanf("%d %d", &a, &b); printf("%d %d", a + b, a * b); -> Option AQuick Check:scanf with & and printf sum then product [OK]Quick Trick: Print sum first, product second with correct scanf [OK]Common Mistakes:Forgetting & in scanfSwapping sum and product orderUsing wrong operators in printf
Master "Input and Output" in C9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More C Quizzes Conditional Statements - Else–if ladder - Quiz 12easy Loop Control Statements - Goto statement overview - Quiz 11easy Loops - For loop - Quiz 8hard Loops - Do–while loop - Quiz 10hard Loops - For loop - Quiz 9hard Loops - For loop - Quiz 2easy Operators and Expressions - Why operators are needed - Quiz 5medium Operators and Expressions - Increment and decrement operators - Quiz 2easy Variables and Data Types - Basic data types - Quiz 14medium Variables and Data Types - Scope of variables - Quiz 8hard