This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to round off the return value

hello anyone here wants to help me...i want the return value to be rounded off for example:
TotalComponent=235
PartialComponent=90
per=38.3%

but with this function i always get 0 % anyone here want to sugest what should be done

unsigned int CalculatePercentage(int TotalComponent,int PartialComponent){
int per;

per= (PartialComponent/TotalComponent)*100;
return (float)per;
}

Parents
  • Pardon me. I said "... one of which divides into the other to yield a signed int, which is further divided by an int ..."

    That should be multiplied by an int. Multiplying the integer result of division does not suddenly cause a fractional result of the division to appear. Like I said, think about the 'type of' and 'results of' your subexpressions.

Reply
  • Pardon me. I said "... one of which divides into the other to yield a signed int, which is further divided by an int ..."

    That should be multiplied by an int. Multiplying the integer result of division does not suddenly cause a fractional result of the division to appear. Like I said, think about the 'type of' and 'results of' your subexpressions.

Children
No data