Respuesta :
Answer:
The question seem incomplete as the list is not given and the programming language is not stated;
To answer this question, I'll answer this question using Python programming language and the program will allow user input.
Input will stop until user enters 0
The program is as follows
newlist = []
print("Input into the list; Press 0 to stop")
userinput = int(input("User Input:"))
while not userinput == 0:
newlist.append(userinput)
userinput = int(input("User Input:"))
is_ascending = "True"
i = 1
while i < len(newlist):
if(newlist[i] < newlist[i - 1]):
is_ascending = "False"
i += 1
print(newlist)
print(is_ascending)
Explanation:
This line declares an empty list
newlist = []
This line prompts gives instruction to user on how to stop input
print("Input into the list; Press 0 to stop")
This line prompts user for input
userinput = int(input("User Input:"))
This next three lines takes input from the user until the user enters 0
while not userinput == 0:
newlist.append(userinput)
userinput = int(input("User Input:"))
The next line initialized "True" to variable is_ascending
is_ascending = "True"
The next 5 line iterates from the index element of the list till the last to check if the list is sorted
i = 1
while i < len(newlist):
if(newlist[i] < newlist[i - 1]):
is_ascending = "False"
i += 1
The next line prints the list
print(newlist)
The next line prints the value of is_ascending
print(is_ascending)