Question: C program - In the standard input, you are given a sequence of integers. For each positive integer n in the input, you must print

C program - In the standard input, you are given a sequence of integers. For each positive integer n in the input, you must print one number in one line of output, which is the sum of all numbers from 1 to n, including n. The program should end after reading a zero or a negative number, which is guaranteed to happen. Input The input consists of a sequence of integers, one integer per line. Output For each integer n in the input, your program must check that it is a positive integer. If it is a positive integer, your program must print the sum of all numbers from 1 to n, including n, on a line by itself. After this, the program must read the next integer, and so on. The first time your program reads a zero or a negative integer, it must end without any further output example. usually given the input in an .in file not iostream.

Input 1 2 5 10 100 0 output 1 3 15 55 5050

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!