Skip to content

Commit 3f5a2bb

Browse files
authored
Update README.md
1 parent e1f1fb9 commit 3f5a2bb

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

Chapter05/README.md

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
# Chapter05: Statements
2-
## [Exercise 5.1](Chapter05/5.01.txt)
2+
## [Exercise 5.1](5.01.txt)
33
What is a null statement? When might you use a null statement?
4-
## [Exercise 5.2](Chapter05/5.02.txt)
4+
## [Exercise 5.2](5.02.txt)
55
What is a block? When might you might use a block?
6-
## [Exercise 5.3](Chapter05/5.03.cpp)
6+
## [Exercise 5.3](5.03.cpp)
77
Use the comma operator (§ 4.10, p. 157) to rewrite the while loop from
88
§ 1.4.1 (p. 11) so that it no longer requires a block. Explain whether this rewrite im-
99
proves or diminishes the readability of this code.
10-
## [Exercise 5.4](Chapter05/5.04.txt)
10+
## [Exercise 5.4](5.04.txt)
1111
Explain each of the following examples, and correct any problems you detect.
1212
```
1313
(a) while (string::iterator iter != s.end()) { /* . . . */ }
1414
(b) while (bool status = find(word)) { /* . . . */ }
1515
if (!status) { /* . . . */ }
1616
```
17-
## [Exercise 5.5](Chapter05/5.05.cpp)
17+
## [Exercise 5.5](5.05.cpp)
1818
Using an if–else statement, write your own version of the program to
1919
generate the letter grade from a numeric grade.
20-
## [Exercise 5.6](Chapter05/5.06.cpp)
20+
## [Exercise 5.6](5.06.cpp)
2121
Rewrite your grading program to use the conditional operator (§ 4.7,
2222
p. 151) in place of the if–else statement.
23-
## [Exercise 5.7](Chapter05/5.07.txt)
23+
## [Exercise 5.7](5.07.txt)
2424
Correct the errors in each of the following code fragments:
2525
```
2626
(a) if (ival1 != ival2)
@@ -36,26 +36,26 @@ Correct the errors in each of the following code fragments:
3636
(d) if (ival = 0)
3737
ival = get_value();
3838
```
39-
## [Exercise 5.8](Chapter05/5.08.txt)
39+
## [Exercise 5.8](5.08.txt)
4040
What is a “dangling else”? How are else clauses resolved in C++?
41-
## [Exercise 5.9](Chapter05/5.09.cpp)
41+
## [Exercise 5.9](5.09.cpp)
4242
Write a program using a series of if statements to count the number of
4343
vowels in text read from cin.
44-
## [Exercise 5.10](Chapter05/5.10.cpp)
44+
## [Exercise 5.10](5.10.cpp)
4545
There is one problem with our vowel-counting program as we’ve im-
4646
plemented it: It doesn’t count capital letters as vowels. Write a program that counts
4747
both lower- and uppercase letters as the appropriate vowel—that is, your program
4848
should count both ’a’ and ’A’ as part of aCnt, and so forth.
49-
## [Exercise 5.11](Chapter05/5.11.cpp)
49+
## [Exercise 5.11](5.11.cpp)
5050
Modify our vowel-counting program so that it also counts the number
5151
of blank spaces, tabs, and newlines read.
52-
## [Exercise 5.12](Chapter05/5.12.cpp)
52+
## [Exercise 5.12](5.12.cpp)
5353
Modify our vowel-counting program so that it counts the number of
5454
occurrences of the following two-character sequences: ff, fl, and fi.
55-
## [Exercise 5.13](Chapter05/5.13.txt)
55+
## [Exercise 5.13](5.13.txt)
5656
Each of the programs in the highlighted text on page 184 contains a
5757
common programming error. Identify and correct each error.
58-
## [Exercise 5.14](Chapter05/5.14.cpp)
58+
## [Exercise 5.14](5.14.cpp)
5959
Write a program to read strings from standard input looking for du-
6060
plicated words. The program should find places in the input where one word is fol-
6161
lowed immediately by itself. Keep track of the largest number of times a single repeti-
@@ -65,7 +65,7 @@ else print a message saying that no word was repeated. For example, if the input
6565
how now now now brown cow cow
6666
```
6767
the output should indicate that the word now occurred three times.
68-
## [Exercise 5.15](Chapter05/5.15.txt)
68+
## [Exercise 5.15](5.15.txt)
6969
Explain each of the following loops. Correct any problems you detect.
7070
```
7171
(a) for (int ix = 0; ix != sz; ++ix) { /* . . . */ }
@@ -75,18 +75,18 @@ Explain each of the following loops. Correct any problems you detect.
7575
for (ix != sz; ++ix) { /* . . . */ }
7676
(c) for (int ix = 0; ix != sz; ++ix, ++ sz) { /* . . . */ }
7777
```
78-
## [Exercise 5.16](Chapter05/5.16)
78+
## [Exercise 5.16](5.16)
7979
The while loop is particularly good at executing while some condition
8080
holds; for example, when we need to read values until end-of-file. The for loop is
8181
generally thought of as a step loop: An index steps through a range of values in a
8282
collection. Write an idiomatic use of each loop and then rewrite each using the other
8383
loop construct. If you could use only one loop, which would you choose? Why?
84-
## [Exercise 5.17](Chapter05/5.17.cpp)
84+
## [Exercise 5.17](5.17.cpp)
8585
Given two vectors of ints, write a program to determine whether
8686
one vector is a prefix of the other. For vectors of unequal length, compare the num-
8787
ber of elements of the smaller vector. For example, given the vectors containing 0,
8888
1, 1, and 2 and 0, 1, 1, 2, 3, 5, 8, respectively your program should return true.
89-
## [Exercise 5.18](Chapter05/5.18.txt)
89+
## [Exercise 5.18](5.18.txt)
9090
Explain each of the following loops. Correct any problems you detect.
9191
```
9292
(a) do
@@ -102,29 +102,29 @@ Explain each of the following loops. Correct any problems you detect.
102102
int ival = get_response();
103103
} while (ival);
104104
```
105-
## [Exercise 5.19](Chapter05/5.19.cpp)
105+
## [Exercise 5.19](5.19.cpp)
106106
Write a program that uses a do while loop to repetitively request two
107107
strings from the user and report which string is less than the other.
108-
## [Exercise 5.20](Chapter05/5.20.cpp)
108+
## [Exercise 5.20](5.20.cpp)
109109
Write a program to read a sequence of strings from the standard input
110110
until either the same word occurs twice in succession or all the words have been read.
111111
Use a while loop to read the text one word at a time. Use the break statement to
112112
terminate the loop if a word occurs twice in succession. Print the word if it occurs
113113
twice in succession, or else print a message saying that no word was repeated.
114-
## [Exercise 5.21](Chapter05/5.21)
114+
## [Exercise 5.21](5.21)
115115
Revise the program from the exercise in § 5.5.1 (p. 191) so that it looks
116116
only for duplicated words that start with an uppercase letter.
117-
## [Exercise 5.22](Chapter05/5.22.cpp)
117+
## [Exercise 5.22](5.22.cpp)
118118
The last example in this section that jumped back to begin could be
119119
better written using a loop. Rewrite the code to eliminate the goto.
120-
## [Exercise 5.23](Chapter05/5.23.cpp)
120+
## [Exercise 5.23](5.23.cpp)
121121
Write a program that reads two integers from the standard input and
122122
prints the result of dividing the first number by the second.
123-
## [Exercise 5.24](Chapter05/5.24.cpp)
123+
## [Exercise 5.24](5.24.cpp)
124124
Revise your program to throw an exception if the second number is
125125
zero. Test your program with a zero input to see what happens on your system if you
126126
don’t catch an exception.
127-
## [Exercise 5.25](Chapter05/5.25.cpp)
127+
## [Exercise 5.25](5.25.cpp)
128128
Revise your program from the previous exercise to use a try block to
129129
catch the exception. The catch clause should print a message to the user and ask
130130
them to supply a new number and repeat the code inside the try.

0 commit comments

Comments
 (0)