while loop

इंटरमीडिएट R

Filip Schouwenaars

DataCamp Instructor

while loop

while(condition) {
  expr
}
while(ctr <= 7) {
इंटरमीडिएट R

while loop

while(condition) {
  expr
}
while(ctr <= 7) {
  print(paste("ctr is set to", ctr))
इंटरमीडिएट R

while loop

while(condition) {
  expr
}
while(ctr <= 7) {
  print(paste("ctr is set to", ctr))
  ctr <- ctr + 1
}
इंटरमीडिएट R

while loop

while(condition) {
  expr
}
while(ctr <= 7) {
  print(paste("ctr is set to", ctr))
  ctr <- ctr + 1
}
"ctr is set to 1"
इंटरमीडिएट R

while loop

while(condition) {
  expr
}
while(ctr <= 7) {
  print(paste("ctr is set to", ctr))
  ctr <- ctr + 1
}
"ctr is set to 2"
इंटरमीडिएट R

while loop

while(condition) {
  expr
}
while(ctr <= 7) {
  print(paste("ctr is set to", ctr))
  ctr <- ctr + 1
}
"ctr is set to 7"
इंटरमीडिएट R

while loop

while(condition) {
  expr
}
while(ctr <= 7) {
  print(paste("ctr is set to", ctr))
  ctr <- ctr + 1
}
  • कोई आउटपुट नहीं
इंटरमीडिएट R

while loop

ctr <- 1
while(ctr <= 7) {
  print(paste("ctr is set to", ctr))
  ctr <- ctr + 1
}
"ctr is set to 1"
"ctr is set to 2"
...
"ctr is set to 7"
ctr
8
इंटरमीडिएट R

while loop

ctr <- 1
while(ctr <= 7) {
  print(paste("ctr is set to", ctr))
  ctr <- ctr + 1
}
इंटरमीडिएट R

अनंत while loop

ctr <- 1
while(ctr <= 7) {
  print(paste("ctr is set to", ctr))

}
"ctr is set to 1"
"ctr is set to 1"
"ctr is set to 1"
"ctr is set to 1"
"ctr is set to 1"
"ctr is set to 1"
"ctr is set to 1"
...
इंटरमीडिएट R

break स्टेटमेंट

ctr <- 1
while(ctr <= 7) {
  if(ctr %% 5 == 0) {
    break
  }
  print(paste("ctr is set to", ctr))
  ctr <- ctr + 1
}
"ctr is set to 1"
"ctr is set to 2"
"ctr is set to 3"
"ctr is set to 4"
इंटरमीडिएट R

अभ्यास करते हैं!

इंटरमीडिएट R

Preparing Video For Download...