O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Numeric Input

A program that performs calculations on predefined numbers is a good start, but most programs need to perform operations on data from the outside world. So let's extend the example again as shown in Listing 4.1.

Listing 4.1. Getting Numeric Input from the User
 1: #include <iostream> 2: 3: using namespace std; 4: 5: int main(int argc, char* argv[]) 6: { *7: int Dividend = 1; *8: cout << "Dividend: "; *9: cin >> Dividend; *10: *11: int Divisor = 1; *12: cout << "Divisor: "; *13: cin >> Divisor; 14: 15: int Result = (Dividend/Divisor); 16: cout << Result << endl; 17: 18: // Note: You must type something before the Enter key 19: char StopCharacter; *20: cout << endl << "Press a key and \"Enter\": "; *21: cin >> StopCharacter; 22: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required