Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an application that shows the sum of 1 to n for every n from1 to 50. That

ID: 3608901 • Letter: W

Question

Write an application that shows the sum of 1 to n for every n from1 to 50. That is the program needs to print 1(the sum of 1 alone),3 (the sum of 1 and 2), 6 (the sum of 1,2,3),10(the sum of1,2,3,4,) etc.

Can someone please show me how to do this. I have a general ideabut for some reason I am missing something that I cant think of.Its at the top of my head but i cannot put it into code

this is what i have so far:

#include<iostream>
#include<conio.h>
using namespace std;

int main()
{
    int n;
    for(n=1; n<=50; n++)
       cout<<n+<<endl;
    getch();
}

the above code compiles and out puts the integers 1-50 I need helpwith the rest. Thanks



Explanation / Answer

please rate - thanks #include<iostream>
using namespace std;
int main()
{
    int n,i,sum;
    for(n=1; n<=50; n++)
       {sum=0;
       for(i=1;i<=n;i++)
          sum+=i;
        cout<<"The sum ofthe numbers from 1 to "<<n<<" is:"<<sum<<endl;
        }
   system("pause");
   return 0;
}


/*   sample output The sum ofthe numbers from 1 to 1 is: 1
The sum of the numbers from 1 to 2 is: 3
The sum of the numbers from 1 to 3 is: 6
The sum of the numbers from 1 to 4 is: 10
The sum of the numbers from 1 to 5 is: 15
The sum of the numbers from 1 to 6 is: 21
The sum of the numbers from 1 to 7 is: 28
The sum of the numbers from 1 to 8 is: 36
The sum of the numbers from 1 to 9 is: 45
The sum of the numbers from 1 to 10 is: 55
The sum of the numbers from 1 to 11 is: 66
The sum of the numbers from 1 to 12 is: 78
The sum of the numbers from 1 to 13 is: 91
The sum of the numbers from 1 to 14 is: 105
The sum of the numbers from 1 to 15 is: 120
The sum of the numbers from 1 to 16 is: 136
The sum of the numbers from 1 to 17 is: 153
The sum of the numbers from 1 to 18 is: 171
The sum of the numbers from 1 to 19 is: 190
The sum of the numbers from 1 to 20 is: 210
The sum of the numbers from 1 to 21 is: 231
The sum of the numbers from 1 to 22 is: 253
The sum of the numbers from 1 to 23 is: 276
The sum of the numbers from 1 to 24 is: 300
The sum of the numbers from 1 to 25 is: 325
The sum of the numbers from 1 to 26 is: 351
The sum of the numbers from 1 to 27 is: 378
The sum of the numbers from 1 to 28 is: 406
The sum of the numbers from 1 to 29 is: 435
The sum of the numbers from 1 to 30 is: 465
The sum of the numbers from 1 to 31 is: 496
The sum of the numbers from 1 to 32 is: 528
The sum of the numbers from 1 to 33 is: 561
The sum of the numbers from 1 to 34 is: 595
The sum of the numbers from 1 to 35 is: 630
The sum of the numbers from 1 to 36 is: 666
The sum of the numbers from 1 to 37 is: 703
The sum of the numbers from 1 to 38 is: 741
The sum of the numbers from 1 to 39 is: 780
The sum of the numbers from 1 to 40 is: 820
The sum of the numbers from 1 to 41 is: 861
The sum of the numbers from 1 to 42 is: 903
The sum of the numbers from 1 to 43 is: 946
The sum of the numbers from 1 to 44 is: 990
The sum of the numbers from 1 to 45 is: 1035
The sum of the numbers from 1 to 46 is: 1081
The sum of the numbers from 1 to 47 is: 1128
The sum of the numbers from 1 to 48 is: 1176
The sum of the numbers from 1 to 49 is: 1225
The sum of the numbers from 1 to 50 is: 1275
Press any key to continue . . . */
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote