Saturday, May 22, 2010

Can anyone answer this please?

Can anyone code a program in C++ to find the remainder of a number without using the modulo operator?

Can anyone answer this please?
Well, yes. You divide using floating values, take only the fractional part, and multiply that fractional part back by the value you had initially to get the remainder.


Of course, that is very inefficient, but that will work.
Reply:Yes, here is one snippet:





a = (int) (x / y);


b = a * y;


r = x - b;
Reply:yes take on this:


float a, b, r;


r=a%b





i guess this can help


No comments:

Post a Comment