␡
- 2.1 Introduction
- 2.2 First Program in C++: Printing a Line of Text
- 2.3 Modifying Our First C++ Program
- 2.4 Another C++ Program: Adding Integers
- 2.5 Memory Concepts
- 2.6 Arithmetic
- 2.7 Decision Making: Equality and Relational Operators
- 2.8 Wrap-Up
- Summary
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
- Making a Difference
From the author of
Answers to Self-Review Exercises
2.1 |
|
2.2 |
|
2.3 |
|
2.4 |
|
2.5 |
(See program below.) 1 // Calculate the product of three integers
2 #include <iostream> // allows program to perform input and output
3 using namespace std; // program uses names from the std namespace
4
5 // function main begins program execution
6 int main()
7 {
8 int x; // first integer to multiply
9 int y; // second integer to multiply
10 int z; // third integer to multiply
11 int result; // the product of the three integers
12
13 cout << "Enter three integers: "; // prompt user for data
14 cin >> x >> y >> z; // read three integers from user
15 result = x * y * z; // multiply the three integers; store result
16 cout << "The product is " << result << endl; // print result; end line
17 } // end function main
|
2.6 |
|
