New here in c++. I need some help with designing a C++ code using a for loop. Prof stated that I cannot use anything else other than a for loop to design this program so I was wondering what to do from here. Here is the question
Get the number of terms from the user and calculate the following sum using a for loop:
sum = 4/5 – 8/25 + 12/125 - …
Example: numterms = 1, sum = 4/5 or 0.8
numterms = 2, sum = 12/25 or 0.48
numterms = 0, sum = 0
Display the result in a complete sentence which includes the number of terms and the sum at the end.
If anyone can help me with this I will be grateful.
I know we like being helpful, but we need to be careful about doing somebody's homework for him (or her). Now Tepples has a mostly functioning program (although not all of the requirements have been met), and has done none of the work.
We like to have the poster try first and then give assistance at the point where he or she is stuck. That way the poster learns something rather than just being given a solution.
Agreed doug4, except for the fact that the OP can only use a for loop so i suspect functions haven't been taught yet so aren't allowed. Plus it doesn't output a complete sentence or handle the user input part so the OP still has some work to do.