Quiz Question 1 of 5
When designing a program to sum all odd numbers between two integers n1
and n2
, what potential pitfalls must be considered to ensure the loop correctly includes n1
and n2
in the sum?
Choose the correct answer below:
-
A
Ensuring that
n1
andn2
are both positive integers. -
B
Making sure the loop only iterates over even numbers to improve efficiency.
-
C
Properly initializing the sum variable outside the loop and checking that the loop includes both boundaries, regardless of their odd/even nature.
-
D
Using a decrementing loop to account for negative values of
n1
andn2
.