/* testfunc03.cpp CIS 150 2008-06-10 David Klick This program demonstrates how to create and call a function that has multiple arguments and a return value. */ #include #include using std::cin; using std::cout; void cont(); int sum(int x, int y); // function prototype int main(int argc, char* argv[]) { int num1, num2; cout << "Enter two integers: "; cin >> num1 >> num2; cout << "The sum of the two integers is " << sum(num1, num2) << '\n'; cont(); return 0; } /* int sum(int a, int b); Arguments: int a: an arbitrary integer value int b: an arbitrary integer value Returns: the sum of the two ints passed in as args This function adds two integers and returns the result. */ int sum(int a, int b) { return a+b; } /* void cont(); Arguments: none Returns: nothing Clears input buffer and pauses waiting for user to press Enter. */ void cont() { if (cin.rdbuf()->sungetc() != -1 && cin.get() != '\n') cin.ignore(80,'\n'); cout << "Press enter to continue..."; cin.get(); }