R Programs to Add, Sub, Mul, and Div
Basic Arithmetic Operations in R:
1. Addition: In R, addition is a basic arithmetic operation performed using the +
operator. It is used to add two or more numerical values.
2. Subtraction: Subtraction is performed in R using the -
operator. It subtracts the right operand from the left operand.
3. Multiplication: The *
operator is used for multiplication in R. It multiplies two or more numerical values.
4. Division: Division is performed in R using the /
operator. It divides the left operand by the right operand.
R Programs for Basic Arithmetic Operations:
Input:
2+3 //Add 2-3 //Sub 2*3 //Mul 2/3 //Div 2+2+3*4-4/3 // Add, Mul, Sub, Div
Output:
5 [1] -1 [1] 6 [1] 0.6666667 [1] 14.66667
(Or)
With input variable:
x=6 y=2 x + y x-y x*y x/y
Output:
8 4 12 3