Code: using System; class test { static void Main() { int divident = 0; int divisor = 0; int division = 0; int rest = 0; Console.Write("divident: "); divident = Convert.ToInt32(Console.ReadLine()); Console.Write("divisor: "); divisor = Convert.ToInt32(Console.ReadLine()); Console.Write("division: " +division); division = (divident / divisor); Console.Write(" rest: " +rest); rest = (divident % divisor); } } my program always returns 0 in division and the rest and I have no idea what's wrong.
The return value of the calculus "a/b" (a and b are integers) is always an integer. If a<b, the return value is always a 0. For Ex: 1/2 = 0 not 0.5 ; 5/2 = 2 not 2.5 I don't think the rest is the same to the division (returns 0). You can use type cast to convert one of two operands (divident or divisor) into another type of number such as float type like as "division = (float) divident/divisor ;" the division have to be declared as a float. Hope that help !