you need to do this then
c = (int)x%(int)y; //cast the other two vars as ints mod won't work for floats
you need to do this then
c = (int)x%(int)y; //cast the other two vars as ints mod won't work for floats
K, it works now. Just need to allow the user to access the function in the first place. Unfortunately, it's giving me an "undeclared" error. *yawn*
EDIT: Hah, its reason for being undeclared was that modulus isn't a legal function name (or so my observations tell me). With my previous plus() and minus() functions, it was probably the same problem!
O yea you cant do that lol... Use things like MyModulus :P
I'm just calling it mod(). I'm just gonna assimilate mod() into the division half of diviminus() so that it outputs both the result of division and the remainder, and then I'll be pretty much done with the calculator.
Sounds good to me. I noticed you fixed the double entrys at some point. Forgot to mention that.
Double entries? *confused*
A while back you had to enter y twice to get into the function :P guess it was longer ago than I thought lol.
Oh, yeah. I mentioned that earlier, and said it had to do wit haccedentally calling "cin" twice.
Speaking of bugs, I have a minor but weird one on in the text-based game I'm writing. It's on another topic if you want to take a look.
That will result in loss of precision. If you don't want that, include <math.h> and use the fmod() function. It takes two double [floating-point] arguments and moduluses them.you need to do this then
c = (int)x%(int)y;
Code:#include <math.h> printf("%lf", fmod(10.0, 8.2));
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
You mean <cmath> and cout, right? THis is the C++ part of the board. Thanks, though. ^_^ (if you can't tell, ^_^ is a smiley).
EDIT: Hey, that works pretty well! I just implemented it.
Last edited by linkofazeroth; 08-28-2005 at 04:19 PM.
Sorry, and you're welcome.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.