|
|
|
|
eXercise #9
Iteration using
FOR...DO
- Write short programs
using FOR..TO..DO loops to print the following output:
- abcdefghijklmnopqrstuvwxyz
- zyxwvutsrqponmlkjihgfedcba
- 1 2 3 4 5
6 7 8 9 10 11 12 13 14 15
- 2 4 6 8 10
12 14 16 18 20 22 24 26 28 30
- 1 4 9 16
25 36 49 64 81 100 121 144 169 196 225
- 1024 512
256 128 64 32 16 8 4 2 1
- The sum of all
the numbers from 1 to 100.
- The sum of the
squares of the numbers from 1 to 10.
- Use a for loop
to write out 100 random numbers between 0 and 99, 20 to a line. At
the end of this output, the sum and the average of the numbers should
also be printed.
- HOW RANDOM IS
RANDOM
Write a program that generates 100 random numbers between 0 and 5,
tallying the number of 0's, 1's .. 5's, then outputting the results
in graph form as such:
0: ***********************
1: ************************
2: ******************
3: ***********
4: *********************
5: *****************
Experiment with bigger
numbers - if the random number generator is good, there should be equal
numbers of each value generated.
|
|
|
|
|
|
|