consider the following program.\ncount ← 1\nsum ← 0\nrepeat 10 times\nsum ← sum + count\ncount ← count +…

consider the following program.\ncount ← 1\nsum ← 0\nrepeat 10 times\nsum ← sum + count\ncount ← count + 2\ndisplay sum\n56 mark for review\nwhich of the following describes the result of executing the program?\na the program displays the sum of the even integers from 0 to 10.\nb the program displays the sum of the even integers from 0 to 20.\nc the program displays the sum of the odd integers from 1 to 9.\nd the program displays the sum of the odd integers from 1 to 19.
Answer
Answer:
D. The program displays the sum of the odd integers from 1 to 19.
Explanation:
Step1: Initial values
count = 1, sum = 0
Step2: First iteration
sum = sum + count = 0+1 = 1, count = count + 2 = 1 + 2 = 3
Step3: Second iteration
sum = sum + count = 1+3 = 4, count = count + 2 = 3 + 2 = 5
Step4: General pattern
count starts at 1 and is incremented by 2 each time. It will take on values 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 in 10 - iterations. And sum accumulates these odd - numbered values. So the program calculates the sum of odd integers from 1 to 19.