1. 程式人生 > >C 判斷兩個數是否為倍數關係問題

C 判斷兩個數是否為倍數關係問題

問題:

Write a program that reads two integers, and determines and prints if the first is a multiple of the second

#include<stdio.h>
#include<stdlib.h>


int main(void) {
	int a, b;

	while (1) {
		printf("Input two integers:");
		scanf_s("%d %d", &a, &b);
		if (a%b == 0) {
			printf("%d is a multiple of %d by a factor of %d\n", a, b, a / b);
		}
	}


	system("pause");
	return 0;
}