//functionBehavior.cpp
//implement a prototype and function call.
#include <iostream>
using std::cout;
using std::endl;
#include <string>
using std::string;
void displayMessage(string message); //function prototype
int main(){
string message="Hello World!\n";
displayMessage(message); //function call
return 0; //indicates success
}//end main
//function implementation
void displayMessage(string message){
cout<<message<<endl;
}//end function displayMessage
When you call a data type in the front, that isn't void, you must return a value that is that data type. So with double in front of the function name, you must return a number that is a double.
Here is what it would look within a piece of code:
1 2 3 4 5 6 7 8 9 10
//the function that was created previously goes here
int main()
{
double average = 0.0;
cout << "enter two numbers: ";
cin >> x >> y;
average = calAverage(x, y); //this puts the two values within the function then sets the return value into average
cout << average; //shows average
return 0; //end program
}