Using int Variables and Constants
A variable allows the program to perform its calculation outside of the cout statement.
1: #include <iostream> 2: 3: using namespace std; 4: 5: int main(int argc, char* argv[]) 6: { *7: const int Dividend = 6; *8: const int Divisor = 2; *9: *10: int Result = (Dividend/Divisor); *11: Result = Result + 3;// Result is now its old value+3=6 *12: *13: cout << Result << endl; 14: 15: // Note: You must type something before the Enter key 16: char StopCharacter; 17: cout << endl << "Press a key and \"Enter\": "; 18: cin >> StopCharacter; 19: 20: return 0; 21: }
Lines 7–13 have been changed. |
Lines 7 and 8 declare variables ...
Get SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.