 # R Program to divide two vectors

September 16, 2021, Learn eTutorial
1085

## How to divide two vectors

Here we explain how to write an R program to do division using two vectors. We have to provide two vector values for the division. For the calculation of vector division here we use the division(/) operator.  In this R program, we accept the vector values into variables A and B. The result value of vectors is assigned variable C. Finally variable C is printed as the output vector.

## ALGORITHM

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 division using the / operator

STEP 4: First print the original vectors

STEP 5: Assign the result of division value to vector C as C=A/B

STEP 6: print the vector C as result vector

## R Source Code

```                                          ```A = c(10, 20, 30)
B = c(20, 10, 40)
print("Original Vectors are:")
print(A)
print(B)
print("After dividing Vectors:")
C = A / B
print(C)
```
```

## OUTPUT

``` "Original Vectors are:"
 10 20 30
 20 10 40
 "After dividing Vectors:"
 0.50 2.00 0.75
```