anonymous
  • anonymous
in c++ programming, the modulus function (%) can only be done for integer data types..why is that? i mean why cant yo use it for float?
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
RedPrince
  • RedPrince
if you use %d then it is use for all data type but %i for integers, %c for characters and %s for strings But %d is use for all these data types!!
anonymous
  • anonymous
sure? because i never came across all those...
anonymous
  • anonymous
You can use, it's not just overloaded with %. Check fmod() : http://www.cplusplus.com/reference/clibrary/cmath/fmod/

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
oh then my book must be wrong..
anonymous
  • anonymous
Maybe it's because cmath is a external lib. C/C++ itself does not allow it, but, on the other hand, both are minimal languages: they don't have an I/O built-in. Well, anyway, hope I helped you, cmath is a nice lib :-)
RedPrince
  • RedPrince
Yes I am sure because i use all of these!!!!!!!!!
anonymous
  • anonymous
It kind of makes sense to me that floating point numbers are not supported by the modulo operation. The modulo operation gives you the remainder after an integer division (so 12 % 10 = 2). But what would be the remainder of a floating point division? Take e.g. 10 / 2.1 = 4.762. Apart from rounding errors, a floating point number is always fully divisible, so it won't have a remainder. What would be the point of a modulo operation without a remainder?

Looking for something else?

Not the answer you are looking for? Search for more explanations.