Sum the Numbers with a Loop

Easy

Complete the sumTo function so it uses a for loop to add every integer from 1 up to and including n. The program prints sumTo(1), sumTo(5), sumTo(10), and sumTo(100). Once your output is correct, switch the assembly panel to -O0 and find the loop: locate the back-edge (the conditional jump whose target is a label above it) and the loop-condition compare that feeds it.

Success Criteria

Your code must pass 1 test case(s) to complete this exercise. 4 hint(s) are available if you need help.

Sign in to track your progress

You can work on exercises as a guest, but sign in to track your progress and save your submissions.

This platform is built by its community

Every lesson, project, and tool on HelloC++ is funded by sponsors. Join them and help shape what we build next.

Become a Patron