Exercise 4.1
- What does each program print
for location : 1 .. 20
put "*" ..
end for
for initial : 'J' .. 'P'
put "\"", initial, "\""
end for
for value : 1 .. 25
if value mod 3 = 0 then
put value
end if
end for
for countDown : 5 .. 1
put countDown, " seconds and counting"
end for
var last : int := 5
for count : -2 .. last
put count:2, last:2
last := last - 1
end for
for i : 14 .. 14
put i
end for
- Write a program that will print a table containing the integers from one to forty along with their squares, cubes, square roots, and reciprocals. The table should contain appropriate headings and be neatly formatted.
- Modify your program so that it inserts a blank line after every fifth line of the table.
- Write a program to find the largest value in a collection of N real numbers, where the value of N is the first data item read by your program. The program should print all the numbers read before printing the largest. Test the program with (at least) the following sets of data.
- 3 2.7 -0.63 5.12
- 0
- 4 -6.2 -1.33 -4 -7.9
|
|