Skip to content

Commit

Permalink
Create Loops
Browse files Browse the repository at this point in the history
For Loop
While Loop
  • Loading branch information
PrajwalKatyal authored Aug 3, 2019
1 parent f64cc39 commit 4ef1cc4
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Loops
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#For Loop

years = c(1995, 1998,1984,1936,2005,1947)
for (yr in years) {
print(yr)
}

for (yr in years) {
if(yr < 1980){
print('Old')
}else{
print('Not that old')
}

}

#While Loop

count = 1
while (count <= 5) {
print(c('Iteration number: ', count))
count = count+1
}


count = 1
while (count <= 4) {
print(c('This is the iteration number: ', count ))

print(movies[count,"name"])
count = count + 1
}

0 comments on commit 4ef1cc4

Please sign in to comment.