How to use the mod in C \ C ++?

3

How do I use the MOD function in C \ C ++? (N MOD 2) = 0 I have to use this line of my code.

    
asked by anonymous 03.04.2014 / 18:51

1 answer

10

The MOD operator is % .

int n = 40;
if (n % 2 == 0) {
    cout << num << " é par";
}

Additionally see std::modulus

    
03.04.2014 / 18:53