T4Tutorials .PK

VU Past Papers CS201-Importants MCQs on Arithmetic Expressions

Q#1: What is the problem statement in the sample program?
(A) Calculate the total age of ten students
(B) Sort out the ages of ten students
(C) Calculate the average age of a class of ten students
(D) Prompt the user to enter the age of each student
Answer: (C) Calculate the average age of a class of ten students

Q#2: Which data type is used for the variables “age1, age2, …, age10”?
(A) double
(B) float
(C) int
(D) char
Answer: (C) int

Q#3: Why is the data type of “AverageAge” declared as int?
(A) To store only whole numbers
(B) To store real numbers with decimal points
(C) To allow the use of expressions in calculations
(D) To ensure accurate calculations
Answer: (A) To store only whole numbers

Q#4: What is the purpose of the “cin” statement in the program?
(A) Display the average age
(B) Take input from the user
(C) Sort the ages of students
(D) Calculate the total age
Answer: (B) Take input from the user

Q#5: How is the user prompted to enter the age of the first student?
(A) cout << “Please input the age of the first student: “;
(B) cout << “Enter the age of the first student: “;
(C) cout << “Age of the first student: “;
(D) cout << “Please enter the age of first student : “;
Answer: (A) cout << “Please input the age of the first student: “;

Q#6: What is the significance of the statement “TotalAge = age1 + age2 + … + age10;”?
(A) Calculate the average age
(B) Display the total age
(C) Sort the ages of students
(D) Calculate the sum of ages
Answer: (D) Calculate the sum of ages

Q#7: How is the average age calculated in the program?
(A) AverageAge = TotalAge / 10.0;
(B) AverageAge = TotalAge / 10;
(C) AverageAge = TotalAge * 10;
(D) AverageAge = TotalAge – 10;
Answer: (B) AverageAge = TotalAge / 10;

Q#8: Why is the decimal part truncated in the average age calculation?
(A) It is intentional for accurate results
(B) It is a programming error
(C) It simplifies the calculation
(D) It allows the use of real numbers
Answer: (A) It is intentional for accurate results

Q#9: What is the purpose of the “cout” statement at the end of the program?
(A) Display the average age
(B) Display the total age
(C) Sort the ages of students
(D) Prompt the user to enter the age of each student
Answer: (A) Display the average age

Q#10: What is the purpose of parentheses in expressions in C?
(A) They are optional and can be omitted
(B) They force the order of evaluation
(C) They are used for multiplication
(D) They indicate the power operator
Answer: (B) They force the order of evaluation

Q#11: How is the quadratic equation “y = ax² + bx + c” written in C?
(A) y = a * x * x + b * x + c;
(B) y = a * (x * x) + (b * x) + c;
(C) y = a * x * x + b * y + c;
(D) y = a * x * x + b * x + c;
Answer: (A) y = a * x * x + b * x + c;

Q#12: What does the expression “x = a * (x + b * (y + c * z * z))” represent?
(A) Quadratic equation
(B) Cubic equation
(C) Nested expression
(D) Linear equation
Answer: (C) Nested expression

Q#13: How is the equation “(b² – 4ac) / 2a” written in C without using parentheses?
(A) b * b – 4 * a * c / 2 * a
(B) (b * b – 4 * a * c) / (2 * a)
(C) b2 – 4ac / 2a
(D) (b2 – 4ac) / (2a)
Answer: (B) (b * b – 4 * a * c) / (2 * a)

Q#14: What happens if parentheses are used incorrectly in expressions?
(A) It has no effect on the result
(B) It causes a compilation error
(C) It improves the readability of the expression
(D) It may change the result of the expression
Answer: (D) It may change the result of the expression

Q#15: How is the expression “x = a(x + b(y + cz²))” written in C?
(A) x = a * (x + b * (y + c * z * z))
(B) x = a * x + b * y + c * z * z
(C) x = a * (x * x) + (b * x) + c
(D) x = a * x + b * (y + c * z * z)
Answer: (A) x = a * (x + b * (y + c * z * z))

Q#16: What is the significance of the “main()” function in the program?
(A) It displays the average age
(B) It sorts the ages of students
(C) It calculates the total age
(D) It is the starting point of the program
Answer: (D) It is the starting point of the program

Q#17: Why is the “cout” statement used in the program?
(A) To take input from the user
(B) To declare variables
(C) To display output to the user
(D) To calculate the average age
Answer: (C) To display output to the user

Q#18: How many students’ ages are taken as input in the program?
(A) 5
(B) 8
(C) 10
(D) 12
Answer: (C) 10

Q#19: What is the purpose of the “TotalAge” variable in the program?
(A) To store the average age
(B) To store the total age
(C) To display the result
(D) To prompt the user
Answer: (B) To store the total age

Q#20: Why is the data type of “AverageAge” declared as int instead of float?
(A) To allow decimal values
(B) To improve program efficiency
(C) To avoid data type errors
(D) To ensure accurate calculations
Answer: (C) To avoid data type errors

Q#1: What is the problem statement in the sample program?
(A) Calculate the total age of ten students
(B) Sort out the ages of ten students
(C) Calculate the average age of a class of ten students
(D) Prompt the user to enter the age of each student
Answer: (C) Calculate the average age of a class of ten students

Q#2: Which data type is used for the variables “age1, age2, …, age10”?
(A) double
(B) float
(C) int
(D) char
Answer: (C) int

Q#3: Why is the data type of “AverageAge” declared as int?
(A) To store only whole numbers
(B) To store real numbers with decimal points
(C) To allow the use of expressions in calculations
(D) To ensure accurate calculations
Answer: (A) To store only whole numbers

Q#4: What is the purpose of the “cin” statement in the program?
(A) Display the average age
(B) Take input from the user
(C) Sort the ages of students
(D) Calculate the total age
Answer: (B) Take input from the user

Q#5: How is the user prompted to enter the age of the first student?
(A) cout << “Please input the age of the first student: “;
(B) cout << “Enter the age of the first student: “;
(C) cout << “Age of the first student: “;
(D) cout << “Please enter the age of first student : “;
Answer: (A) cout << “Please input the age of the first student: “;

Q#6: What is the significance of the statement “TotalAge = age1 + age2 + … + age10;”?
(A) Calculate the average age
(B) Display the total age
(C) Sort the ages of students
(D) Calculate the sum of ages
Answer: (D) Calculate the sum of ages

Q#7: How is the average age calculated in the program?
(A) AverageAge = TotalAge / 10.0;
(B) AverageAge = TotalAge / 10;
(C) AverageAge = TotalAge * 10;
(D) AverageAge = TotalAge – 10;
Answer: (B) AverageAge = TotalAge / 10;

Q#8: Why is the decimal part truncated in the average age calculation?
(A) It is intentional for accurate results
(B) It is a programming error
(C) It simplifies the calculation
(D) It allows the use of real numbers
Answer: (A) It is intentional for accurate results

Q#9: What is the purpose of the “cout” statement at the end of the program?
(A) Display the average age
(B) Display the total age
(C) Sort the ages of students
(D) Prompt the user to enter the age of each student
Answer: (A) Display the average age

Q#10: What is the purpose of parentheses in expressions in C?
(A) They are optional and can be omitted
(B) They force the order of evaluation
(C) They are used for multiplication
(D) They indicate the power operator
Answer: (B) They force the order of evaluation

Q#11: How is the quadratic equation “y = ax² + bx + c” written in C?
(A) y = a * x * x + b * x + c;
(B) y = a * (x * x) + (b * x) + c;
(C) y = a * x * x + b * y + c;
(D) y = a * x * x + b * x + c;
Answer: (A) y = a * x * x + b * x + c;

Q#12: What does the expression “x = a * (x + b * (y + c * z * z))” represent?
(A) Quadratic equation
(B) Cubic equation
(C) Nested expression
(D) Linear equation
Answer: (C) Nested expression

Q#13: How is the equation “(b² – 4ac) / 2a” written in C without using parentheses?
(A) b * b – 4 * a * c / 2 * a
(B) (b * b – 4 * a * c) / (2 * a)
(C) b2 – 4ac / 2a
(D) (b2 – 4ac) / (2a)
Answer: (B) (b * b – 4 * a * c) / (2 * a)

Q#14: What happens if parentheses are used incorrectly in expressions?
(A) It has no effect on the result
(B) It causes a compilation error
(C) It improves the readability of the expression
(D) It may change the result of the expression
Answer: (D) It may change the result of the expression

Q#15: How is the expression “x = a(x + b(y + cz²))” written in C?
(A) x = a * (x + b * (y + c * z * z))
(B) x = a * x + b * y + c * z * z
(C) x = a * (x * x) + (b * x) + c
(D) x = a * x + b * (y + c * z * z)
Answer: (A) x = a * (x + b * (y + c * z * z))

Q#16: What is the significance of the “main()” function in the program?
(A) It displays the average age
(B) It sorts the ages of students
(C) It calculates the total age
(D) It is the starting point of the program
Answer: (D) It is the starting point of the program

Q#17: Why is the “cout” statement used in the program?
(A) To take input from the user
(B) To declare variables
(C) To display output to the user
(D) To calculate the average age
Answer: (C) To display output to the user

Q#18: How many students’ ages are taken as input in the program?
(A) 5
(B) 8
(C) 10
(D) 12
Answer: (C) 10

Q#19: What is the purpose of the “TotalAge” variable in the program?
(A) To store the average age
(B) To store the total age
(C) To display the result
(D) To prompt the user
Answer: (B) To store the total age

Q#20: Why is the data type of “AverageAge” declared as int instead of float?
(A) To allow decimal values
(B) To improve program efficiency
(C) To avoid data type errors
(D) To ensure accurate calculations
Answer: (C) To avoid data type errors

Exit mobile version