Hi guys. I am having a problem with a project for my Computer Science class. The basic program works but I am having trouble getting the output the professor asked for. Here is my source code:
As I said, the main program works. It calculates the sum, square and sum of the cubes. However, the professor has asked for a specific output. He wants the output to say the following:Code:#include<iostream> #include<iomanip> using namespace std; #define clear() cout << (char)(27) << '[' << '?' << '3' << 'l'; #define cur_yx(y,x) cout << (char)(27) << '[' << y << ';' << x << 'H'; main() { int start, end, sum, square, sum_cubes, sum_terms, cubes_terms; cout<<"Input Series Start Here: "; cin>>start; cout<<"Input Series End Here: "; cin>>end; sum_terms = start, start++; cubes_terms = start*start*start; cubes_terms++; sum = (((0.5)*(end*end)) + (0.5*end)); square = sum * sum; sum_cubes = (end*(end + 1) / 2) * (end*(end + 1) / 2); cout<<"Sum = "<<start<<" + "<<sum_terms++<<" = "<<sum<<endl; cout<<"Square of Sum = "<<square<<endl<<endl; cout<<"Sum of Series Terms Cubes = "<<cubes_terms<<" = "<<sum_cubes<<endl<<en\ dl; }
For example, if the two integers were 1 and 3, the output should
be:
Sum = 1+ 2 + 3 = 6
Square of Sum = 36
Square of Cubes = 1 + 8 + 27 = 36
What I am having trouble with is how to get the program to output 1+2+3 or 1+8+27 along with the answer, which in this is 36. Any help would be appreciated. Thanks.



LinkBack URL
About LinkBacks



Want to add some
The professor instructed us to place that in every program.