/* SimpleIO1.cpp CIS 150 Dave Klick May 2008 Very simple C++ I/O using cin and cout. */ #include using std::cout; // used for output using std::cin; // used for input using std::endl; // newline (and flushes output buffer) void cout(); int main() { // declare variables double num1 = 0; double num2 = 0; double sum = 0; // get user input cout << "Please enter two numbers: "; cin >> num1; cin >> num2; // do calculations sum = num1 + num2; // display results cout << "You entered " << num1 << " and " << num2 << endl; cout << "The sum is " << sum << endl; cont(); return 0; } void cont() { if (cin.rdbuf()->sungetc() != -1 && cin.get() != '\n') cin.ignore(80,'\n'); cout << "Press enter to continue..."; cin.get(); }