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

AT&T; LTE 12:26 PM Done DOC012518-01252018103755... Write a ++ progran which ans

ID: 3881951 • Letter: A

Question

AT&T; LTE 12:26 PM Done DOC012518-01252018103755... Write a ++ progran which ansvers the following question How far do you have to go in adding together the sequence for the sun to exceed 25,000 That is, your progran should keep adding together the above number sequence until the sun gets to be more than 25,000, at which point it should print out both the sun and the last nunber added which made the sun go over 25,000 Please print out appropriate nessages with each of these, 1ike: Note that, since you have seen in class an easy way of adding arithnetie serles,you ean actually check the computer's work by to think about: what might you do to convince yourself of your progran's correctness if you iantE kno hov to sus up arithnetie series?) C++ source code progran (not Please hand in a paper copy of the conpiler listing) and a copy of your output. There are several possible ways of getting a printout of ogging the session,sending output directly toa printer, and writing output toafile for assignnent, and as the output is not voluninous, you can just cEY the outost by hand ontoa sheet of paper and hand that in along with your source code printing. As this is your first

Explanation / Answer

// you are not using the for loop appropriately. THis is how you should use it with while loop and increasing the iterator value in every loop

int sum=1,i=2;

while(sum<=25000){

sum+=i;

i++;

}

cout<<"The final sum is "<<sum<<endl;cout<<"The last number is "<<i<<endl;

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