Exp 1-5

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Lab Experiments in R

1. Write a program to check whether a year (int)


entered by the user is a leap year or not.
Program:

Output:

2. Write an r program to find the sum of natural


numbers without formula using the if-else
statement and the while loop.
Program:
Output:

3. Write a program that prints the grades of the


students according to the marks obtained. The
grading of marks should be as follows:

Marks Grades
800-1000 A+
700-800 A
500-700 B+
400-500 B
150-400 C
Less than 150 D

Program:
Output:

4. Write an r program to make a simple calculator that


can add, subtract, multiply and divide using switch
case and functions.
Program:
Output:
5. Write a set of instructions to create the following
matrix using vectors and rbind() function. Rename
the rows to lang1, lang2 and lang3 respectively and
use the function to access any one element using
row matrix.

Program:

Output:

You might also like