52.6k views
3 votes
Ask the user to input a number less than 100. Print all the numbers from 0 to that number. Which loop correctly does this?

Group of answer choices

num = int (input("Enter a number between 1 and 100: "))
c = num
while (num <= c):
print (c)
c = c + 1

num = int (input("Enter a number between 1 and 100: "))
c = 0

while (num <= 0):
print (c)
c = c + 1

num = int (input("Enter a number between 1 and 100: "))
c = 0

while (c <= num):
print (c)
c = c + 1

num = int (input("Enter a number between 1 and 100: "))
c = 0

while (num >= 0):
print (c)
c = c + 1

1 Answer

1 vote

Answer:

num = int(input("Enter a number between 1 and 100: "))

c = 0

while c <= num:

print(c)

c += 1

Step-by-step explanation:

This loop correctly prints all the numbers from 0 to the input number because it starts with c = 0 and continues to print and increment c until it reaches the value of num. The other loops either do not initialize c correctly or have incorrect conditions for the while loop to terminate.

User Gbjbaanb
by
8.6k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.