Write your question here.
what should my function call be
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
usingnamespace std;
int sigmaFromTo(int num1, int num2);
int main ()
{
int num1, num2;
cout << "Enter two integers: ";
cin >> num1 >> num2;
// function call
}
int sigmaFromTo(int from, int to)
{
int sum;
sum = 0;
for (int i=from; i <= to; i++)
sum = sum +i;
return sum;
}
When you call the function, you send in num1 and num2 right? Then you do some shit with it in the function, and then you return sum; Where is that sum gonna go? To Mars? To heaven? By catch I mean, you need to create a variable of the same sort, in this case integer, to insert that returning value.
Which means. This int sum that is in your main -int sum = sigmaFromTo(num1, num2);
Is now equal to whatever you returned from the function