I have the following function:
divisibilidade11(int num);
And the following variables:
int dividendo;
int divisor;
When the user enters the variable 11
for the variable divisor
the function divisibilidade11
will be called and will check if the variable dividendo
is divisible by divisor
. And to check whether it is divisible or not, you will have to follow the criteria: If the sum of this odd-order digit (Sp) subtracted from the odd-order sum (Si) results in 0 or a divisible number of 11, it returns true
and if not, it returns false
.
Example:
The user enters the number
2376
for the variabledividendo
;The user enters the number
11
for the variabledivisor
;The
divisibilidade11
function is called to check whether it is divisible or not;The sum of the odd (Si) = 3 + 6 = 9 is made;
The sum of the pairs (Sp) = 2 + 7 = 9 is made;
Si - Sp = 0; Therefore, therefore, 2376 is divisible by 11.
NOTE: The right-most digit is the first of the odd order.
Example how it would appear to the user:
The function divisibilidade11
has to repeat the process until the result is a one-digit number. If this digit is equal to 0, then the original number is divisible by 11.