the condition of if(b<a) && (c==0)
could be simplified in the following way, if we want to know if a
is divisible by b
would be if(a % b == 0){ //Lo demas }
as you would know, you only need to verify that the module ( %
) of a
and b
equals 0
that is to say the rest is exact, I leave you a proposal of solution:
#include <stdio.h>
int main() {
int a, b;
printf("Ingrese 2 numeros: \n");
scanf("%d%d", &a, &b);
if((a % b == 0) && (b!=0))
{
printf("%d es Divisible entre %d",a,b);
}else{
printf("%d NO es Divisible entre %d",b,a);
}
return 0;
}
Anything or doubt, write to me, Regards.
Update 1:
Condition (b!=0)
was added since the division between 0
does not have a defined value. Suggested change for: eferion