Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

goutham1995 Group Title

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?

  • 2 years ago
  • 2 years ago

  • This Question is Closed
  1. RedPrince Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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!!

    • 2 years ago
  2. goutham1995 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    sure? because i never came across all those...

    • 2 years ago
  3. bmp Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    You can use, it's not just overloaded with %. Check fmod() : http://www.cplusplus.com/reference/clibrary/cmath/fmod/

    • 2 years ago
  4. goutham1995 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    oh then my book must be wrong..

    • 2 years ago
  5. bmp Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    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 :-)

    • 2 years ago
  6. RedPrince Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Yes I am sure because i use all of these!!!!!!!!!

    • 2 years ago
  7. slotema Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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?

    • 2 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.