Multiple Choice
Which code snippet produces the sum of the first n even numbers?
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
Q42: How do you fix this code snippet
Q43: What output does this while loop generate?
Q44: Which of the following is considered a
Q45: Which of the following loops will print
Q46: What will be printed by the statements
Q48: What does the following code snippet display?
Q49: Suppose you must design a program to
Q50: What are the values of i and
Q51: When hand-tracing a portion of code, which
Q52: What will be the output of the