finding out if integer is multiple of 3

this is what i have so far. I need to modify this with arithmetic operators to find out whether or not the integer is a multiple of 3.



#include <iostream>
using namespace std;

int main()

{

int integer;

cout << "Enter number:";
cin >> integer;

if(integer < 0) cout << "This number is negative";
else cout << "This number is positive";


}
This can be done very easily using the modulo (%) operator. It gives the
remainder of a division operation. So, integer%3 will be zero if
integer is divisible by three.
http://www.cplusplus.com/doc/tutorial/operators.html
Last edited on
Topic archived. No new replies allowed.