Skip to content

Commit

Permalink
Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
msatmod committed Aug 30, 2022
1 parent 7f798b0 commit 88bc360
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Day 6/For_loop.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Program for For Loop
# No condition in For Loop

=begin
for VARIABLE_NAME in RANGE
Code
end
=end

for i in 0..5
puts("value of local variable i = #{i}")
end
11 changes: 11 additions & 0 deletions Day 6/For_loop_alternative.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Program for alternative of for Loop

=begin
(RANGE).each do |VARIABLE_NAME|
Code
end
=end

(0..5).each do |i|
puts("value of local variable i = #{i}")
end
13 changes: 13 additions & 0 deletions Day 6/More_on_loops.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# More on loops

8.times do puts "Filly..!" end

4.times {puts "THE MEGA"}

3.upto (7) {puts "Amey"}

3.upto (7) {|i| puts "Amey #{i}"}

7.downto (3) {|i| puts "Amey #{i}"}

0.step(15,5){|i| puts "Hey Filly #{i}"}
15 changes: 15 additions & 0 deletions Day 6/Until_loop.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Program for Until Loop

=begin
until condition do
Code
end
=end

$i = 0
$num = 5

until $i > $num do
puts ("Inside the loop $i = #$i");
$i += 1
end
16 changes: 16 additions & 0 deletions Day 6/Until_modifier.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Program for Until Modifier

=begin
until modifier syntax:
begin
Code
end until condition
=end

$i = 0
$num = 5

begin
puts ("Inside the loop $i = #$i");
$i += 1
end until $i > $num
15 changes: 15 additions & 0 deletions Day 6/While_loop.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Program for While Loop

=begin
while condition do
Code
end
=end

$i = 0
$num = 5

while $i < $num do
puts ("We are inside the loop with $i value = #$i");
$i += 1
end
16 changes: 16 additions & 0 deletions Day 6/While_modifier.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Program for While Modifier

=begin
while modifier syntax:
begin
Code
end while condition
=end

$i = 0
$num = 5

begin
puts ("We are inside the loop with $i value = #$i");
$i += 1
end while $i < $num

0 comments on commit 88bc360

Please sign in to comment.