Friday, December 15, 2023

Program 6- Working with loops in R R Programming Lab - Bsc CS DA and BSC ML And AI -Bharathiar University -

 

B.Sc Computer Science  

R Programming - Lab  

Bharathiar University 

Program 6

Loops in R

Program 6- Write a R program to demonstrate various types of loops

SOURCE CODE:

# R program to demonstrate loops


# application of for loop

week <- c('Sunday',

          'Monday',

          'Tuesday',

          'Wednesday',

          'Thursday',

          'Friday',

          'Saturday')



for (day in week)

{

  print(day)

}


# R program to demonstrate the use of while loop


x = 1

while (x <= 5)

{


  cat("2 x ", x,"=", x*2,"\n")

  x = x + 1

}


# R program to illustrate

# the application of repeat loop


i <- 0

repeat

{

  print("Basic to pro tamil!")

  i = i + 1

  if (i == 5)

  {    

    break

  }

}



OUTPUT:

No comments:

Post a Comment

Program 12 BCA Madras University BCA Object Oriented Programming using C++ Practical Madras University Program 12 Implement a telephone directory using files

  BCA Object Oriented Programming using C++ Practical Madras University  Program 12  Implement a telephone directory using files SOURCE CODE...