1. Repeat 5 Times
repeat 5 then
say "Hello Mewar"
end
2. Count 1 to 10
set i to 1
repeat 10 then
say i
set i to i + 1
end
3. While Loop
set count to 1
while count <= 5 then
say count
set count to count + 1
end
4. Reverse Countdown
set time to 5
while time > 0 then
say time
set time to time - 1
end
say "Launch!"
5. For Loop List
set names to ["Pratap","Sanga","Kumbha"]
for name in names then
say name
end
6. Step Function
set nums to step(1,20,2)
for n in nums then
say n
end
7. Stop Example
set i to 1
repeat 10 then
if i is 5 then
stop
end
say i
set i to i + 1
end
8. Do While Loop
set rounds to 1
do
say rounds
set rounds to rounds + 1
while rounds <= 5
9. Nested Loop
repeat 3 then
repeat 2 then
say "Nested"
end
end
10. Star Pattern
set rows to 5
set i to 1
repeat rows then
set j to 1
repeat i then
print "* "
set j to j + 1
end
newline
set i to i + 1
end
11. Number Triangle
set rows to 5
set i to 1
repeat rows then
say i
set i to i + 1
end
12. Factorial
set num to 5
set fact to 1
set i to 1
repeat num then
set fact to fact * i
set i to i + 1
end
say fact
13. Sum of Numbers
set n to 10
set sum to 0
set i to 1
repeat n then
set sum to sum + i
set i to i + 1
end
say sum
14. Fibonacci
set a to 0
set b to 1
say a
say b
repeat 8 then
set c to a+b
say c
set a to b
set b to c
end
15. Loop Through List
set warriors to ["Veer","Rana","Rajput"]
for w in warriors then
say "Welcome " + w
end