1
I have the following duties :
int testarDivisibilidade(int dividendo, int divisor);
int divisibilidade3(int num);
And the following variables: :
int dividendo;
int divisor;
With the function testarDivisibilidade, I’ll check if the dividendo is divisible by the divisor.
Code :
int divisibilidade3(int num)
{
int res = 0;
while( num > 0 )
{
res += num % 10;
num /= 10;
}
if(res > 9)
return divisibilidade3(res);
else
return ! (res % 3);
int testarDivisibilidade(int dividendo,int divisor) {
if(divisibilidade3(dividendo) == 1) {
printf("%d é divisivel por %d ", dividendo,divisor);
return 1;
}
return 0;
}
I have to check if divisibilidade3returns true to be able to fire the message inside the if. But this giving problem, because for all cases of the dividendo, he returns as true.
Summarizing : How can I correctly check my function divisibilidade3 within the function testarDivisibilidade ?

Wow, thank you very much, it worked correctly. In fact it will only call divisibility function3 if the user chooses divisor 3.
– Mondial