asked 222k views
5 votes
Your classmate is frustrated because the code that was designed to add up her five quiz grades is not working properly.

What change would you suggest to your classmate based on this code?for (i=1;i<=5;i++){ sum=0sum=sum+i;}

1 Answer

5 votes

Answer:

sum = 0 must be before for loop. If inside for loop, it will keep resetting sum to 0 each iteration.

Step-by-step explanation:

hope this helps

answered
User AlexBerd
by
7.9k points