#5, First Floor, 4th Street , Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to implement Simple Calculator in R?
Description

To implement a Simple Calculator using R programming.

Process
  • Step 1 : Creating function for all basic arithmetic operations.
  • Step 2: Get Operation from user.
  • Step 3: Get input numbers from user.
  • Step 4 : Output of corresponding operation using switch statement
Sapmle Code

# Create functions for all simple arithmetic operations

add return(x+y)
}
sub return(x-y)
}
mult return(x*y)
}
div return(x/y)
}
mod return(x%%y)
}

#User Input
cat(“Select Operation :\n1) Addition\n2) Subtraction\n3) Multiplication\n4) Division\n5) Modulo Division”)
choice n1 n2

#Switch Statement
result

#Result
cat(“Result : “,result)

Screenshots