fastread homefastrread library fastread menu

R Programming : Find the Multiplication Table of a Number

Tutorial by:Maria Ghoste      Date: 2016-06-10 02:37:48

❰ Previous Next ❱

Source Code

# Program to find the multiplication
# table (from 1 to 10)
# of a number input by the user

# take input from the user
num = as.integer(readline(prompt="Enter Number: "))

# use for loop to iterate 10 times
for(i in 1:10) {
    print(paste(num,'x',i,'=',num*i))
}

Output


Enter Number: 7
[1] "7 x 1 = 7"
[1] "7 x 2 = 14"
[1] "7 x 3 = 21"
[1] "7 x 4 = 28"
[1] "7 x 5 = 35"
[1] "7 x 6 = 42"
[1] "7 x 7 = 49"
[1] "7 x 8 = 56"
[1] "7 x 9 = 63"
[1] "7 x 10 = 70"

Here, we ask the user for a number and display the multiplication table upto 10. We use for loop to iterate 10 times.

❰ Previous Next ❱


R Programming

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website