-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex1.rb
54 lines (40 loc) · 1.03 KB
/
ex1.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#puts "1 \n1 \n1 \n1 \n1 "
#simple print number "1" "10" times
10.times do
puts 1
end
puts "---------------------------------------------"
puts "----------------for loop---------------------"
puts "---------------------------------------------"
for i in 1..10
if i == 5
puts "Fish"
end
puts i
end
puts "------------------------------------------------------"
puts "-------------------while loop-------------------------"
puts "------------------------------------------------------"
j=1
while j <= 10
puts j
j+=1
end
puts "------------------------------------------------------"
puts "-------------------for loop---------------------------"
puts "------------PRINT NUMBERS 1 to 10---------------------"
for k in 1..100 do
if k % 3 == 0
puts k
end
end
puts "------------------------------------------------------"
puts "-------------------each loop--------------------------"
puts "-------------PRINT NUMBERS 1 to 100--------------------"
(1..100).each do |num|
if num % 2 == 0
puts "even"
else
puts num
end
end