R_Prac-4.r
Problem Statement
R_Prac-4.r
Program to add two numbers in R program.
Source Code
r
# Program to add two numbers in R program.
num1 <- as.double(readline(prompt="Enter 1st number: "))
num2 <- as.double(readline(prompt="Enter 2nd number: "))
if(is.na(num1) || is.na(num2)) {
stop("You did not enter a valid number.")
}
print(paste("Result", num1 + num2))1
2
3
4
5
6
7
8
2
3
4
5
6
7
8