You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Exercise 1.2: Change the program to return -1. A return value of -1 is often treated as an indicator that the program failed. Recompile and rerun your program to see how your system treats a failure indicator from main.
> Write a program to print Hello, World on the standard output.
33
32
34
33
```cpp
@@ -41,7 +40,8 @@ int main()
41
40
}
42
41
```
43
42
44
-
##Exercise 1.4
43
+
## Exercise 1.4
44
+
45
45
> Our program used the addition operator, +, to add two numbers. Write a program that uses the multiplication operator, *, to print the product instead.
46
46
47
47
```cpp
@@ -58,7 +58,7 @@ int main()
58
58
}
59
59
```
60
60
61
-
##Exercise 1.5
61
+
##Exercise 1.5
62
62
63
63
> We wrote the output in one large statement. Rewrite the program to use a separate statement to print each operand.
64
64
@@ -81,12 +81,13 @@ int main()
81
81
}
82
82
```
83
83
84
-
##Exercise 1.6
84
+
## Exercise 1.6
85
+
85
86
> Explain whether the following program fragment is legal.
86
87
87
88
It's illegal.
88
89
89
-
**[Error] expected primary-expression before '<<' token**
90
+
**`[Error] expected primary-expression before '<<' token`**
90
91
91
92
Fixed it: remove the spare semicolons.
92
93
@@ -96,11 +97,12 @@ std::cout << "The sum of " << v1
96
97
<< " is " << v1 + v2 << std::endl;
97
98
```
98
99
99
-
##Exercise 1.7
100
+
##Exercise 1.7
100
101
101
102
> Compile a program that has incorrectly nested comments.
> Revise the program you wrote for the exercises in § 1.4.1 (p. 13) that printed a range of numbers so that it handles input in which the first number is smaller than the second.
> http://www.informit.com/title/032174113 contains a copy of Sales_item.h in the Chapter 1 code directory. Copy that file to your working directory. Use it to write a program that reads a set of book sales transactions, writing each transaction to the standard output.
291
+
> <http://www.informit.com/title/032174113> contains a copy of Sales_item.h in the Chapter 1 code directory. Copy that file to your working directory. Use it to write a program that reads a set of book sales transactions, writing each transaction to the standard output.
0 commit comments