Here we are explaining how to write an R program to multiply two vectors. We can give two vector values to calculate the multiplication. For the calculation of vector product here we use the product(*) operator.
Given below are the steps which are used in the R program to multiply two vectors. In this R program, we accept the vector values into variables A and B. The result value of vectors is assigned variable C.Finally the variable C is printed as output vector.
STEP 1: take the two vector values into the variables A,B
STEP 2: Consider C as the result vector
STEP 3: Calculate the vector product using the * operator
STEP 4: First print the original vectors
STEP 5: Assign the result of product value to vector C as C=A*B
STEP 6: print the vector C as result vector
A = c(10, 20, 30) B = c(20, 10, 40) print("Original Vectors are:") print(A) print(B) print("Product of two Vectors:") C = A * B print(C)
 "Original Vectors:"  10 30 6  20 10 40  "Product of two Vectors:"  200 300 240