Hi, I'm not sure what this code does.

``````int total(int value1, int value2)
{
int sum;
sum = value1 + value2;
return sum;

}``````

This method should take in 2 values and calculate the sum and return it. But I don't understand where it returns it to? In my main method I had:

``````string Uinput;
int num1;
int num2;
cout<<"Enter the 2 numbers you want to add"<<endl;
getline(cin,Uinput);
getline(cin,Uinput);
stringstream(Uinput)>>num1>>num2;
total(num1,num2);
//I want to print the sum but how do I get it from the total function????``````

I want to print the sum but how do I get it from the total function???? I don't understand

The function identifier says it all.

``int total(int value1, int value2)``

The 'int' at the beginning tells that your function returns an int value when called. Therefore, it is logical that an 'int' value is return when you call the function at line 8 of your main method.

``total(num1,num2);``

You can declare an int variable at the beginning of your main method for storing the returned value.

``int returnValue;``

Modify line 8 of your main method by assigning the newly declared variable with the return value of your total function.

``returnValue = total(num1,num2);``

Finally, you can do whatever you want with the value of returnValue as it now stores the sum of num1 and num2.