steify avatar

Learning To Code #7 (Loops)

steify

Published: 12 Apr 2021 › Updated: 12 Apr 2021Learning To Code #7 (Loops)

Learning To Code #7 (Loops)

Sum of many numbers. (Exercise for beginners)

  1. Make a loop that will ask the user for a number. Stop the loop if the user's input is 0.
  2. int sum = 0; Add the user's number to the sum until the user's input is 0.

Here is an example of how it should work.
summa.png

This exercise seems to be easy but it's actually not that easy if you haven't heard anything about loops. I recommend learning loops. Once they will be your best friends, especially 'for' loop. In this exercise, you can use 'while' loop which seems easier but at the end of the day I highly recommend you to learn more about 'for' loops.

Unfortunately, I haven't got any time to code right now as I got so much to do off PC. Tomorrow will be a free day for me and then I will dive into learning again.

If you got any questions feel free to hit me up!🤓
Peace!✌️

Leave Learning To Code #7 (Loops) to:

Written by

Read more #coding posts


Best Posts From steify

We have not curated any of steify's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From steify