w3resource

R Programming: Multiply two vectors of integers type and length 3

R Programming: Vector Exercise-4 with Solution

Write a R program to multiply two vectors of integers type and length 3.

Sample Solution :

R Programming Code :

x = c(10, 20, 30)
 y = c(20, 10, 40)
 print("Original Vectors:")
 print(x)
 print(y)
 print("Product of two Vectors:")
 z = x / y
 print(z)

Sample Output:

[1] "Original Vectors:"
[1] 10 20 30
[1] 20 10 40
[1] "Product of two Vectors:"
[1] 0.50 2.00 0.75                         

R Programming Code Editor:



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

Previous: Write a R program to append value to a given empty vector.
Next: Write a R program to divide two vectors of integers type and length 3.

Test your Programming skills with w3resource's quiz.

What is the difficulty level of this exercise?



Follow us on Facebook and Twitter for latest update.