Q#1: What is the purpose of using the double data type in C programming?
Answer: The double data type is used to store floating-point numbers with higher precision than the float data type. It is commonly used when calculations require more accurate decimal values.
Q#2: How does the modulus operator work in C, and when can it be used?
Answer: The modulus operator % returns the remainder after dividing one integer by another. It can only be used with integer values. For example, 10 % 3 gives the result 1.
Q#3: Explain the importance of parentheses in arithmetic expressions and their impact on operator precedence.
Answer: Parentheses are used to control the order of evaluation in arithmetic expressions. Operations inside parentheses are performed first, which helps ensure the correct calculation and avoids ambiguity in expressions.
Q#4: How is user input handled in the sample program to calculate the average age of a class in C?
Answer: In the sample program, user input is taken using the scanf() function. It allows the program to read values entered by the user (such as ages) from the keyboard and store them in variables for further calculations like finding the average.