Puzzle R3

Print N random integers in the range 0..9

[E-2] Write a main() program that prints N random integers in the range 0..9, one per line. Think of this as repeatedly rolling a 10-sided die (with sides numbered 0 to 9). One run of the program outputs:

6
5
4
1
5
7
4
6
8
8

Initialize the random number generator using:

  srand( time(NULL) );

Write this program by making a copy of the previous answer, and modifying it. You should need to change only a few lines.



Previous Page        Answer         Next Page         Home