multiple.c (614B)
1 /* Esercizio 5.17 */ 2 3 #include <stdio.h> 4 5 int multiple(int, int); 6 7 int main() 8 { 9 int num1, num2; 10 11 while(1) { 12 printf("Give me two numbers (^C to end): "); 13 scanf("%d%d", &num1, &num2); 14 15 if(multiple(num1, num2)) 16 printf("%d is multiple of %d\n", num1, num2); 17 else 18 printf("%d is NOT multiple of %d\n", num1, num2); 19 20 } /* end while(1) */ 21 22 return 0; 23 } /* E0F main */ 24 25 /* Check if x is multiple of y */ 26 int multiple(int x, int y) 27 { 28 if(!y) 29 return 0; 30 else if(x > y && !(x % y) || y < 0 && x < y && !(x % y)) 31 return 1; 32 else 33 return 0; 34 35 } /* eof multiple() */ 36