HELP in a logical issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sonhadorPR@gmail.com

    #1

    HELP in a logical issue

    How can I tell a computer, in C++, to give me the reminder on a
    division problem?
    If (Quotient)(Divi sor) + Reminder = Dividend
    How do I get the reminder by itself?
    How do I tell C++ that I want the reminder.
    If I write
    quot = num2/num1; It won't give me the reminder.
    Thank you for your help.
    Roberto Millan, frustrated programmer :/

  • Thomas Tutone

    #2
    Re: HELP in a logical issue

    sonhado...@gmai l.com wrote:
    How can I tell a computer, in C++, to give me the reminder on a
    division problem?
    If (Quotient)(Divi sor) + Reminder = Dividend
    How do I get the reminder by itself?
    How do I tell C++ that I want the reminder.
    If I write
    quot = num2/num1; It won't give me the reminder.
    Thank you for your help.
    Roberto Millan, frustrated programmer :/
    In C++ (and in C), the modulo operator is %. It gives the "remainder"
    of an integral division. For example:

    int i = 7 % 3; // i is now equal to 1, which is the remainder of 7
    divided by 3.

    Best regards,

    Tom

    Comment

    • red floyd

      #3
      Re: HELP in a logical issue

      sonhadorPR@gmai l.com wrote:
      How can I tell a computer, in C++, to give me the reminder on a
      division problem?
      If (Quotient)(Divi sor) + Reminder = Dividend
      How do I get the reminder by itself?
      How do I tell C++ that I want the reminder.
      If I write
      quot = num2/num1; It won't give me the reminder.
      Thank you for your help.
      Roberto Millan, frustrated programmer :/
      >
      What book are you reading that doesn't mention the % (modulo) operator?

      Comment

      • Jerry Coffin

        #4
        Re: HELP in a logical issue

        In article <1156820719.525 645.21770@i3g20 00cwc.googlegro ups.com>,
        sonhadorPR@gmai l.com says...
        How can I tell a computer, in C++, to give me the reminder on a
        division problem?
        C++ provides the modulus operator (%), which will generally do the job.
        If you have to deal with negative numbers, you may need to do a little
        extra work to get exactly what you want though.

        --
        Later,
        Jerry.

        The universe is a figment of its own imagination.

        Comment

        • Frederick Gotham

          #5
          Re: HELP in a logical issue

          posted:
          How can I tell a computer, in C++, to give me the reminder on a
          division problem?
          If (Quotient)(Divi sor) + Reminder = Dividend
          How do I get the reminder by itself?
          How do I tell C++ that I want the reminder.
          If I write
          quot = num2/num1; It won't give me the reminder.
          Thank you for your help.
          Roberto Millan, frustrated programmer :/

          If you want both, then consider "div":


          manual=compleat &Search=div&pag e=stdlib.html#d iv

          --

          Frederick Gotham

          Comment

          Working...