Multiple Choice
Which code snippet produces the sum of the first n even numbers? (0 is not considered an even number.)
A) int sum = 0;
For (int i = 1; i <= n; i++)
{
If (i % 2 == 0)
{
Sum = sum + i;
}
}
B) int sum = 0;
For (int i = 1; i <= n; i++)
{
Sum = sum + i * 2;
}
C) int sum = 0;
For (int i = 0; i < n; i++)
{
If (i % 2 == 0)
{
Sum = sum + i;
}
}
D) int sum;
For (int i = 1; i <= n; i++)
{
Sum = sum + i * 2;
Correct Answer:

Verified
Correct Answer:
Verified
Q2: Insert a statement that will correctly terminate
Q3: When will the loop in the following
Q10: Choose the loop that is equivalent to
Q10: What is the output of this code
Q32: What is the output of the following
Q59: What is the output of the following
Q67: What is the output of the code
Q84: What is the last output line of
Q95: In the following code snippet, when does
Q127: Which of the following loops executes exactly