Basically i have a loop, and i need to increase z by 30 every time y-x is greater than or equal to 1000.
X and Y are inputted by the user
the value of Z depends on the difference of x and y,
the loop only works when Y is greater than or equal to X
If there is another way to do this without loops, I'd be happy to consider it.
so for example
4500 - 4000 = 500, so Z = 0
4500 - 3500 = 1000, so Z = 30
2000 - 947 = 1053, so Z = 30
3500 - 1000 = 2500, so Z = 60
4000 - 900 = 3100, so Z = 90
10000 - 500 = 9500, so Z = 270
the answer should be the same for most C languages,
this is what i have - sometimes works but is very hit and miss:
//x and y already inputted
double z = 0;
while (y >= x)
{
y = y - x;
if (y >= 1000)
{
z+=30;
}
}
but it doesn't work, even though I've been told it should work
any help?

New Topic/Question
Reply




MultiQuote





|