In this program, You will learn how to find quotient without using division operator in R.

Example: How to find quotient without using division operator in R

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
{ x <- as.integer(readline(prompt = "Enter first number :")) y <- as.integer(readline(prompt = "Enter second number :")) c = 0 while (x >= y) { x = x - y c = c + 1 } print(paste("Quotient is :", c)) } |

The code first reads in values for `x`

and `y`

from the user and stores them as integers. It then initializes a variable `c`

to 0.

The code then enters a `while`

loop which continues to execute as long as `x`

is greater than or equal to `y`

. Inside the loop, the code subtracts `y`

from `x`

and increments `c`

by 1. This continues until `x`

is no longer greater than or equal to `y`

.

After the `while`

loop has finished executing, the code prints the value of `c`

to the console. This value is the quotient of `x`

and `y`

, which is the number of times `y`

can be subtracted from `x`

before `x`

becomes less than `y`

.

For example, if `x`

is 10 and `y`

is 3, the code would execute the `while`

loop 4 times and `c`

would be 4. This is because 3 can be subtracted from 10 four times before 10 becomes less than 3.

1 2 3 4 5 |
Enter first number :4 Enter second number :2 [1] "Quotient is : 2" |