Question: Enter a C program to print a list of values, each value being the sum of all integers from 1 to n. The first three
Enter a C program to print a list of values, each value being the sum of all integers from 1 to n. The first three lines of the output would be:
sum[1] = 1
sum[2] = 3
sum[3] = 6
So the first line shows the sum of all integers from 1 to 1, which is 1.
The second line shows the sum of all integers from 1 to 2, which is 1 + 2 = 3
The third line shows 1 + 2 + 3 = 6.
Your program should print all of the sums from 1 to 10. Your program should use a loop. In your answer, you do not have to have the #include, or the 'int main(...)', just show any variable declarations and assignments, and the loop.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
