5
I have the following function :
divisibilidade11(int num);
And the following variables: :
int dividendo;
int divisor;
When the user enters with the type 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 even-order digit (Sp) subtracted from the odd-order sum (Si), results in 0 or a number divisible by 11, it returns true
and if not, it returns false
.
Example :
User enters with number
2376
for the variabledividendo
;User enters with number
11
for the variabledivisor
;Is called the function
divisibilidade11
, to check whether or not it is divisible;The sum of the impairments (Si) = 3+6 = 9;
Sum of pairs (Sp) = 2+7 = 9;
Si - Sp = 0; Therefore, 2376 is divisible by 11.
NOTE: The right-most digit is the odd-order first digit.
Example of how it would appear to the user :
The function divisibilidade11
you have to repeat the process until the result is a number with a digit. If this digit is 0, then the original number is divisible by 11.
Not from exercise. Why it counts the rightmost digit as odd-order first.
– Mondial
Thanks for the answer, I realized after performing a rereading of your question what you meant. Please see my answer, and ask your questions if necessary.
– Nexus
I’ll try to do here by following the criteria of divisibility, if I can I put the code.
– Mondial