Homework

March 20, 2020

Today’s exercise is somebody’s homework:

Write a program that displays the digits from 1 to n then back down to 1; for instance, if n = 5, the program should display 123454321. You are permitted to use only a single for loop.

The questioner did not specify what should happen when n reaches 10, so we will specify 0 < n < 10.

Your task is to write the requested program; if you like, think of other ways to write that program. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Pages: 1 2