The Exercise
Consider the following code:
Code:
#include <iostream>
using namespace std;
int main()
{
int low;
int high;
cout << "Enter a value:";
cin >> low;
cout << "Enter a value:";
cin >> high;
cout << "Thank you for the input!" << endl;
int sum=0;
for(int i=low; i<=high; i++)
sum+=i*i;
cout << "The sum from i=" << low << " to " << high << " of i^2 is :"
<< sum << endl;
return 0;
}
Your task is to rewrite this program so that it performs exactly the same task but has a main
function that must look exactly like the following:
Code:
int main()
{
int low=get_value();
int high=get_value();
cout << "Thank you for the input!" << endl;
cout << "the sum from i=" << low << " to " << high << " of i^2 is :"
<< sumi2(low,high) << endl;
return 0;
}
Could someone please help me with this?
I've been trying for hours, im new to c++ and just need some help.