R Programming: Take input from the user and display the values, print the version of R installation

R Programming: Basic Exercise-1 with Solution

Write a R program to take input from the user (name and age) and display the values. Also print the version of R installation.

Sample Solution :

R Programming Code :

name = readline(prompt="Input your name: ")
age =  readline(prompt="Input your age: ")
print(paste("My name is",name, "and I am",age ,"years old."))

Sample Output:

Input your name: 
Input your age: 
[1] "My name is  and I am  years old."
[1] "R version 3.4.4 (2018-03-15)"                         

R Programming Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: R Programming Exercises Home.
Next: Write a R program to get the details of the objects in memory.

Test your Python skills with w3resource's quiz

What is the difficulty level of this exercise?