C - Operators and ExpressionsWhy does the expression 5 / 2 in C result in 2 instead of 2.5?ABecause both operands are integers, so integer division truncates the decimalBBecause C automatically rounds all divisions downCBecause 5 and 2 are treated as floats by defaultDBecause the division operator always returns an integerCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand operand types in divisionBoth 5 and 2 are integers, so C performs integer division.Step 2: Integer division truncates decimal partInteger division drops the decimal, so 5 / 2 = 2, not 2.5.Final Answer:Because both operands are integers, so integer division truncates the decimal -> Option AQuick Check:Integer division truncates decimals in C [OK]Quick Trick: Integer division drops decimals, use float for decimals [OK]Common Mistakes:Thinking C rounds automaticallyAssuming operands are floatsBelieving division always returns int
Master "Operators and Expressions" in C9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More C Quizzes C Basics and Execution Environment - Why C is widely used - Quiz 8hard C Basics and Execution Environment - Writing first C program - Quiz 4medium Conditional Statements - If statement - Quiz 4medium Conditional Statements - If–else statement - Quiz 13medium Conditional Statements - Nested conditional statements - Quiz 8hard Input and Output - Using scanf for input - Quiz 15hard Input and Output - Using printf for output - Quiz 10hard Loops - Do–while loop - Quiz 14medium Variables and Data Types - Variable declaration and initialization - Quiz 15hard Variables and Data Types - Constants and literals - Quiz 15hard