Thread: help

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    3

    Question help

    im writing a program in the program a lage amount of numbers is inputed and i need to find which of these numbers are devisible by 3,i dont now how to finde if a number is devisible by 3 so please help.

  2. #2
    Registered User penney's Avatar
    Join Date
    Jan 2003
    Posts
    47
    Use the modulus operator - % and if the result is 0 then it's divisible by 3.

    if( (num % 3)==0 ) /* Num is divisible by 3 */

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    127
    The modulus operator (%) returns the remainder of a division. If the remainder is zero then the operand on the left side is divisible by the operand on the right side.
    Code:
    if (number % 3 == 0) {
      /* Divisible by 3 */
    }

Popular pages Recent additions subscribe to a feed