Absolute C++ Chapter 2 Self-Test Exercise(5)
27.
2 4 6 8
28.
Hello 10
Hello 8
Hello 6
Hello 4
Hello 2
29.
2.000000 1.500000 1.000000 0.500000
30.
a.
for(int i=1;i<=10;i++) {
if(i<5&&i!=2)
cout<<'X';
}
b.
for(int i=1;i<=10;i+=3)
cout<<'X';
c.
for(long n=100;n<=1000;n+=100)
cout<<'X';
31.
1024 1
1024 2
1024 3
1024 4
1024 5
1024 6
1024 7
1024 8
1024 9
1024 10
the last value of the log is the exponent of 2 equal the value n which is 1024
32.1024 1
33. infinite loop
34.a.for b.while c.while d.do-while
35.infinite loop
36. stop the switch that the break statement is embeded in and the closest loop
37
1 times 10 = 10
1 times 9 = 9
.
.
.
1 times 1 = 1
2 times 10 = 20
2 times 9 = 18
.
.
.
2 times 1 = 2
3 times 10 = 30

浙公网安备 33010602011771号