1: //integers_text.cpp
2: //Illustrates text and integer output combined, as well as
3: //declaration of, and assignment to, an integer variable
4: //(a variable of data type "int").
6: #include <iostream>
7: #include <iomanip>
8: using namespace std;
10: int main()
11: {
12: cout << "\nThis program displays some combinations "
13: "of integer values with text.\n\n";
15: cout << "There are " << 7 << " days in a week." << endl;
16: cout << "There are " << 12 << " months in a year." << endl;
18: int numberOfDays; //Reserves a memory location
19: numberOfDays = 365; //Assigns 365 to that location
20: cout << "There are (usually) " << numberOfDays
21: << " days in a year.\n\n";
23: cout << setw(10) << ""
24: "This line starts in column " << 11 << ".\n";
26: cout << "\nHere is a list of " << 4 << " items:\n"
27: << setw(12) << "computers" << setw(6) << 80 << endl
28: << setw(12) << "monitors" << setw(6) << 80 << endl
29: << setw(12) << "mice" << setw(6) << 120 << endl
30: << setw(12) << "printers" << setw(6) << 6 << endl << endl;
32: cout.setf(ios::left, ios::adjustfield);
33: cout << "Here is the same list of " << 4 << " items:\n"
34: << setw(12) << "computers" << setw(6) << 80 << "<<\n"
35: << setw(12) << "monitors" << setw(6) << 80 << "<<\n"
36: << setw(12) << "mice" << setw(6) << 120 << "<<\n"
37: << setw(12) << "printers" << setw(6) << 6 << "<<\n";
39: cout << endl;
40: }