-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |