79.1k views
0 votes
Write a program that prints the number 1 through 10 using a while loop

User Meqwz
by
7.0k points

1 Answer

5 votes
Which programming language are you working in?

Here is how you could achieve this in Python:

establish a counter, starting at 1.
While your counter is 10 or less, do two things:
print the counter,
and increase the counter by 1.

code:
counter = 1

while counter <= 10:
print(counter)
counter = counter + 1

Those last two lines should be indented.
User Mowgli
by
7.1k points