[Solved] C# error in dividing two integers [closed]


When dividing integers the result will be an integer. This means that you are expecting a value such as 0.75 (which you appear to be thinking you’ll multiply by 100 to get a percentage) then the integer value returned will be only the 0 which is the leading integer. The remainder would be available with the % modulus operator.

However, get a percentage like you seem to want, you’ll need to divide using doubles or float values.

double perst;
double qcount;
double acount;

perst = (acount / qcount) * 100;

The MSDN article on the division operator – Good idea to read.

5

solved C# error in dividing two integers [closed]