While Loop
While Loop
Write a program that uses a while loop to print the numbers from 1 to 10.
Even Numbers
Write a program that prints all even numbers from 2 to 20 using a while loop.
Sum of Numbers
Write a program that asks the user for a number N and then calculates the sum of numbers
from 1 to N using a while loop.
Multiplication Table
Write a program that takes an input number and uses a while loop to print its multiplication
table up to 12.
Reverse Countdown
Write a program that prints numbers from 10 down to 1, then prints "Liftoff!".
3. Sum of Numbers (1 to N)
pseudocode
CopyEdit
DISPLAY "Enter a number:"
INPUT N
SET sum = 0
SET i = 1
WHILE i <= N DO
sum = sum + i
i = i + 1
END WHILE
DISPLAY "Sum of numbers from 1 to", N, "is", sum
4. Multiplication Table
pseudocode
CopyEdit
DISPLAY "Enter a number:"
INPUT num
SET i = 1
WHILE i <= 12 DO
DISPLAY num, " x ", i, " = ", num * i
i = i + 1
END WHILE
9. Sum of Digits
pseudocode
CopyEdit
DISPLAY "Enter a number:"
INPUT num
SET sum = 0
WHILE num > 0 DO
SET digit = num MOD 10
sum = sum + digit
num = num DIV 10
END WHILE
DISPLAY "Sum of digits:", sum