Order PDF of any content from our website with a little minor Fee to donate for hard work. Online MCQs are fully free but PDF books are paid. For details: contact whatsapp +923028700085 Important notes based PDF Books are available in very little price, starting from 500/-PKR; Order Now: contact whatsapp +923028700085

VU Past Papers CS201-Most Importants MCQs on Loops

Q#1: What is the purpose of the while loop in the given paragraph?
(A) To display the result
(B) To calculate the sum of integers
(C) To handle overflow conditions
(D) To analyze problems
Answer: (B) To calculate the sum of integers

Q#2: What happens when the condition in the while loop becomes false?
(A) The program gives a compile-time error
(B) The loop is terminated, and control moves to the next statement
(C) Extra bits are allocated for storage
(D) The program enters an infinite loop
Answer: (B) The loop is terminated, and control moves to the next statement

Q#3: What is overflow in the context of the given paragraph?
(A) An error during program compilation
(B) Exceeding the 32-bit limit for storing integers
(C) Incorrect output due to wasted information
(D) A condition that occurs during runtime
Answer: (B) Exceeding the 32-bit limit for storing integers

Q#4: How is the upper limit for the sum of integers handled in the program?
(A) By changing the data type of the variable
(B) By using the modulus operator
(C) By modifying the while loop condition
(D) By changing the value of the ‘number’ variable
Answer: (C) By modifying the while loop condition

Q#5: What does the program prompt the user to enter to make it more reusable?
(A) The sum of integers
(B) The upper limit for the sum
(C) The condition for the while loop
(D) The value of the ‘number’ variable
Answer: (B) The upper limit for the sum

Q#6: In “Sample Program 2,” what is the problem statement?
(A) Calculating the sum of integers
(B) Calculating the factorial of a given number
(C) Displaying the result using the cout statement
(D) Calculating the sum of even numbers
Answer: (D) Calculating the sum of even numbers

Q#7: How is evenness determined in “Sample Program 2”?
(A) By checking if the number is divisible by 2
(B) By using the modulus operator
(C) By checking if the number is odd
(D) By dividing the number by 2
Answer: (B) By using the modulus operator

Q#8: What is the purpose of the modulus operator in determining even numbers?
(A) To check if the number is odd
(B) To calculate the remainder of the division
(C) To divide the number by 2
(D) To perform integer division
Answer: (B) To calculate the remainder of the division

Q#9: What is the consequence of not writing the statement in the while loop?
(A) The loop will execute forever
(B) The loop will terminate immediately
(C) The program will give a runtime error
(D) The loop will execute zero times
Answer: (A) The loop will execute forever

Q#10: How is an infinite loop defined in the given paragraph?
(A) A loop with a true condition that executes zero or more times
(B) A loop with a false condition that executes forever
(C) A loop with a true condition that executes forever
(D) A loop with a false condition that executes zero or more times
Answer: (C) A loop with a true condition that executes forever

Q#11: What is the property of a while loop mentioned in the paragraph?
(A) It always executes once
(B) It may execute zero or more times
(C) It executes exactly N times
(D) It terminates immediately
Answer: (B) It may execute zero or more times

Q#12: What is emphasized regarding the use of braces in the while loop structure?
(A) They are optional and can be omitted
(B) They are necessary to ensure the loop structure
(C) They only affect the loop condition
(D) They are used for displaying results
Answer: (B) They are necessary to ensure the loop structure

Q#13: What is the recommended practice before coding a program?
(A) Compile the program first
(B) Draw the flow chart first
(C) Analyze the problem thoroughly
(D) Execute the program once
Answer: (C) Analyze the problem thoroughly

Q#14: In “Sample Program 3,” what is the problem statement?
(A) Calculating the sum of even numbers
(B) Calculating the factorial of a given number
(C) Displaying the result using the cout statement
(D) Calculating the sum of integers
Answer: (B) Calculating the factorial of a given number

Q#15: What is the definition of the factorial of a number in the given paragraph?
(A) The product of all integers from 1 to N
(B) The sum of all integers from 1 to N
(C) The division of N by all integers from 1 to N
(D) The subtraction of N by all integers from 1 to N
Answer: (A) The product of all integers from 1 to N

Q#16: What is needed to calculate the factorial of a number?
(A) A loop to multiply the number with the next incremented number
(B) A loop to multiply the number with the next decremented number
(C) A loop to add the number with the next incremented number
(D) A loop to add the number with the next decremented number
Answer: (B) A loop to multiply the number with the next decremented number

Q#17: What decreases in each repetition when calculating the factorial?
(A) The number is incremented
(B) The number is decremented
(C) The upper limit is increased
(D) The upper limit is decreased
Answer: (B) The number is decremented

Q#18: What is the key idea behind solving the factorial problem?
(A) Dividing the number by the next incremented number
(B) Multiplying the number with the next incremented number
(C) Subtracting the number by the next incremented number
(D) Adding the number with the next incremented number
Answer: (B) Multiplying the number with the next incremented number

Q#19: How is evenness determined without using the modulus operator?
(A) By checking if the number is divisible by 2
(B) By using the division operator
(C) By using the subtraction operator
(D) By checking if the number is odd
Answer: (A) By checking if the number is divisible by 2

Q#20: What happens when the loop condition in “Sample Program 3” evaluates to false?
(A) The loop is terminated, and control exits the loop structure
(B) The program gives a compile-time error
(C) The loop condition is tested again
(D) The loop executes forever
Answer: (A) The loop is terminated, and control exits the loop structure

Contents Copyrights Reserved By T4Tutorials