R Program to add two numbers by user input

In this program, You will learn how to add two numbers by user input in R.


    x <- readline(prompt="Enter first number :")
    y <- readline(prompt="Enter second number :")

R Program to add two numbers by user input

Example: How to add two numbers by user input in R

{
    x <- readline(prompt="Enter first number :")
    y <- readline(prompt="Enter second number :")

    x <- as.integer(x)
    y <- as.integer(y)

    z = x + y

    print(paste("Addition of two number is :",z))
  }

Output:

Enter first number :12
Enter second number :13
[1] "Addition of two number is : 25"