asked 169k views
3 votes
1. Sum of Numbers

Write a program that asks the user for a positive nonzero integer value. The program should
use a loop to get the sum of all the integers from 1 up to the number entered. For example,
if the user enters 50, the loop will find the sum of 1, 2, 3, 4, . . . 50.

asked
User Nhatnq
by
7.9k points

1 Answer

6 votes

Answer:

Start a for loop from index 0 to the length of the array – 1. In every iteration, perform sum = sum + arr[i]. After the termination of the loop, print the value of the sum

Step-by-step explanation:

answered
User Addmeaning
by
8.6k points

No related questions found