C# Program to find quotient without using the division operator


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


2 = 10 / 5

0 = 5 / 10

Example: How to find quotient without using division operator in C#.

using System;
public class Test
{
	public static void Main(string[] args)
	{
		int x, y, q = 0;
		Console.Write("Enter first number:");
		x = Convert.ToInt32(Console.ReadLine());

		Console.Write("Enter second number:");
		y = Convert.ToInt32(Console.ReadLine());

		while (x >= y)
		{
			x = x - y;
			q++;
		}

		Console.WriteLine("Quotient is:" + q);
	}
}

Output:

Enter first number:5
Enter second number:3
Quotient is:1