Write a program that asks the user to input some numbers. It reads in the numbers, one per line (just use scanf
), until either the user enters in 0
or the user has entered in a total of 10 numbers. At that point, your program repeats all the numbers it has read, followed by the same list of numbers, but in reverse.
Here are two example sessions, where the user input is in bold:
Enter some numbers:
3
4
5
0
3
4
5
5
4
3
This next program uses up all 10 numbers; there is no 0.
Enter some numbers:
1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10
10
9
8
7
6
5
4
3
2
1