Slip12
Write an R Program to calculate Multiplication Table
number <- as.integer(readline("Enter the number: "))
cat("Multiplication Table for", number, ":\n")
for (i in 1:10) {
result <- number * i
cat(number, "x", i,
"=", result, "\n")
}
Output
> number <- as.integer(readline("Enter the number: "))
Enter the number: 4
> cat("Multiplication Table for", number, ":\n")
Multiplication Table for 4 :
> for (i in 1:10) {
+ result <- number * i
+ cat(number, "x", i,
"=", result, "\n")
+ }
4 x 1 = 4
4 x 2 = 8
4 x 3 = 12
4 x 4 = 16
4 x 5 = 20
4 x 6 = 24
4 x 7 = 28
4 x 8 = 32
4 x 9 = 36