Q#1: How does the program extract digits from a four-digit integer using the modulus operator?
Answer: The program uses the modulus operator % with 10 to obtain the last digit of a number (e.g., number % 10). After extracting the last digit, the program divides the number by 10 to remove that digit. This process is repeated to extract all digits of the four-digit number.
Q#2: Why does the program use the float data type for variables in the circle program?
Answer: The program uses the float data type because calculations for diameter, circumference, and area of a circle can produce decimal values. The float type allows the program to store and display numbers with fractional parts.
Q#3: What is the purpose of using flow charts in program design according to the paragraph?
Answer: Flowcharts provide a graphical representation of a program’s logic and sequence of steps. They help programmers understand the flow of the program, design the program structure, and identify possible logical errors before writing the code.
Q#4: Explain the role of relational operators in decision-making statements (if statements).
Answer: Relational operators such as >, <, ==, >=, and <= are used to compare values in conditions. In if statements, they evaluate whether a condition is true or false, allowing the program to execute different blocks of code based on the result.