R Program to find quotient and remainder
In this program, You will learn how to find quotient and remainder in R.
4 / 5 = 0.8
as.integer(4 / 5) = 0
4 %/% 5 = 0
4 %% 5 = 4
Example: How to find quotient and remainder in R
{
x <- readline(prompt = "Enter first number :")
y <- readline(prompt = "Enter second number :")
x <- as.integer(x)
y <- as.integer(y)
q = as.integer(x / y)
q1 = x %/% y
q2 = x / y
r = x %% y
print(paste("Quotient with integer typecast :", q))
print(paste("Quotient with integer division operator:", q1))
print(paste("Quotient is :", q2))
print(paste("Remainder is :", r))
}
Output:
Enter first number :5
Enter second number :3
[1] "Quotient with integer typecast : 1"
[1] "Quotient with integer division operator: 1"
[1] "Quotient is : 1.66666666666667"
[1] "Remainder is : 2"