#include using namespace std; /* general format for a function ( , ...) { // or code, if you prefer... return ; // omit if the return-type is void } */ /* takes in a double, finds the difference of squares, and returns the answer */ double myFunction(double triple) { double answer; answer = triple * triple - 1.0; return answer; } void secondFunction(double &triple) { triple = triple * triple - 1.0; } int main() { double squares, userInput; cout << "What number do you want to try? "; cin >> userInput; // now we call the function - there is no need to re-specify return or parameter types squares = myFunction(userInput); cout << "The difference of squares of " << userInput << " is " << squares << endl; // now we try by reference secondFunction(userInput); cout << "By reference, we get " << userInput << endl; return 0; }