Answer:
The program is written in Python:
num = int(input("User Input: "))
mylist = []
while(num !=0):
mylist.append(num)
num = int(input("User Input: "))
mylist.reverse()
for i in mylist:
print(i,end = ' ')
Step-by-step explanation:
This question is answered using Python and it uses 0 as a sentinel value; i.e. the program stops prompting user for input when user enters 0
This line prompts user for input
num = int(input("User Input: "))
This line declares an empty list
mylist = []
This loop is repeated as long as user enters input other than 0
while(num !=0):
This appends user input to the list
mylist.append(num)
This prompts user for another input
num = int(input("User Input: "))
This reverses the list
mylist.reverse()
The following iteration the list in reverse order
for i in mylist:
print(i,end = ' ')