I'm certain that this part of your assignment can be done using the values that functions can return, and functions' parameter lists. I'll explain this to you in about as much detail as you need.
If you take any old function:
Code:
long int calc ( int v )
{
/** some calculation **/
/** return the result as a value **/
return v * 2;
}
/** ... **/
int x = getint( );
long int total = calc( x );
A function's body, contained in curly braces, are the statements the function will execute.
A function's parameters are values it operates on.
An optional return value stores the result of the process.
To explain this briefly: say you get a value for x, and in this case it's 30. If we examine the parameter list for calc(), we discover that it takes an int as a parameter. As we know, thirty is an int so this is perfect.
I can easily demonstrate how a function in general works by calling calc() with x. calc() operates it's value v, which is now a copy of x's value. It doubles v, storing the result in total. So a function can use values going in as parameters, do something with them, and return the result to where it was called.
Knowing this, you may want to review functions in your textbook, and then start your homework.