Multiplication Table in R Programming Language

Multiplication Table in R Programming Language

num = as.integer(readline(prompt = “Enter a number: “))
# use for loop to iterate 10 times
for(i in 1:5) {
print(paste(num,’x’, i, ‘=’, num*i))
}

Output:

Enter your number: 8
[1] “8 x 1 = 8”
[1] “8 x 2 = 16”
[1] “8 x 3 = 24”
[1] “8 x 4 = 32”
[1] “8 x 5 = 40”

No Comments

Post a Reply