Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

TEST BANK FOR R -Programming manual

Rating
-
Sold
-
Pages
18
Grade
A+
Uploaded on
09-01-2025
Written in
2024/2025

TEST BANK FOR R -Programming manual

Institution
Course

Content preview

CREATED BY FutureBright




R Programming

, 1


Experiment - 01
Q1. Write a program to check whether a yr. entered by the user is a leap year or
not?
Ans:
Input:
# leap year or not
year = as.integer(readline(prompt="Enter a year: "))
if((year %% 4) == 0) {
if((year %% 100) == 0) {
if((year %% 400) == 0) {
print(paste(year,"is a leap year"))
} else {
print(paste(year,"is not a leap year"))
}
} else {
print(paste(year,"is a leap year"))
}
} else {
print(paste(year,"is not a leap year"))
}
Output:
Enter a year: 2070
[1] "2070 is not a leap year"
Enter a year: 3036
[1] "3036 is a leap year"

, 2


Experiment - 02
Q2. WAP to find the sum of natural no. Without formula using if-else
statement and the while loop.
Ans:
Input:
# take input from the user
num = as.integer(readline(prompt = "Enter a number: "))
if(num < 0) {
print("Enter a positive number")
} else {
sum = 0
# use while loop to iterate until zero
while(num > 0) {
sum = sum + num
num = num - 1
}
print(paste("The sum is", sum))
}

Output:
Enter a number: 20
[1] "The sum is 210"
Enter a number: 10
[1] "The sum is 55"
Enter a number: 60
[1] "The sum is 1830"

Written for

Course

Document information

Uploaded on
January 9, 2025
Number of pages
18
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$14.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
FutureBright Eastern Virginia Medical School
Follow You need to be logged in order to follow users or courses
Sold
17
Member since
1 year
Number of followers
0
Documents
220
Last sold
3 months ago
FutureBright

Writing and Academics I offer a full range of online academic services aimed to students who need support with their academics. Whether you need tutoring, help with homework, paper writing, or proofreading, I am here to help you reach your academic goals. My experience spans a wide range of disciplines. I provide different Exams Questions with fly verified answers, textbooks like biology, chemistry, nursing medical books and many more with a very reasonable cost and also provide books in a package deal.

Read more Read less
4.5

4 reviews

5
3
4
0
3
1
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions