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