Q:

What does the following for loop do? What is the final value of sum

0

What does the following for loop do? What is the final value of sum?

int sum = 0;
for (int i = -100; i <= 100; ++i)
sum += i;

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

The loop add all numbers from -100 to 100 inclusive. The value of `sum` is 0.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now