September 24, 2022

Algorithm to print the series 1 to N using while loop

In this tutorial, we are going to write an algorithm to print the series of 1 to N using a while loop. using this algorithm we can write a program to print the series 1 to N using a while loop in most programming languages like java python c++ and c programming.


algorithm to print series of 1 to n using while loop

Algorithm to print the series 1 to N using a while loop.

1. Read N.
2. Set I:=1
3. Repeat Steps 4 and 5 While I <= N:
4.       Write I.
5.       Set I:=I+1.
6. [End of Step 3 loop]
7. Exit.

Here in the above algorithm we first read an integer variable N and then set the initial value of another variable I to 1. and then using the while loop we will execute steps 4 and step 5. means first we will write the value of the I variable to the output screen and then Set the value of I to I + 1. these two step will execute till the value of I become equal to N. and then we will exit from the program.

Leave a Reply

Your email address will not be published. Required fields are marked *