C - Variables and Data TypesWhich of the following is the correct way to declare a variable of type float in C?Aint number = 3.14;Bchar number = 3.14;Cfloat number = 3.14;Dbool number = 3.14;Check Answer
Step-by-Step SolutionSolution:Step 1: Check variable declaration syntaxIn C, to declare a float variable, use the keyword float followed by the variable name and value.Step 2: Match type with valueAssigning 3.14 (a decimal) to a float variable is correct. Other types like int, char, or bool cannot hold decimal values properly.Final Answer:float number = 3.14; -> Option CQuick Check:Decimal numbers use float type [OK]Quick Trick: Use float keyword for decimal numbers [OK]Common Mistakes:Using int for decimal valuesAssigning decimal to charUsing bool for numbers
Master "Variables and Data Types" in C9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More C Quizzes C Basics and Execution Environment - Compilation process in C - Quiz 2easy C Basics and Execution Environment - main function and program entry - Quiz 1easy Conditional Statements - Nested conditional statements - Quiz 5medium Conditional Statements - Switch vs if comparison - Quiz 11easy Conditional Statements - Why conditional logic is needed - Quiz 12easy Loop Control Statements - Why loop control is required - Quiz 4medium Loop Control Statements - Continue statement - Quiz 7medium Loop Control Statements - Goto statement overview - Quiz 9hard Operators and Expressions - Logical operators - Quiz 6medium Variables and Data Types - Type modifiers - Quiz 4medium