write a c program that reads a positive integer,and prints all its factors
时间: 2024-05-29 16:09:52 浏览: 82
c语言中寻找完数并输出其因子
#include <stdio.h>
int main() {
int num, i;
printf("Enter a positive integer: ");
scanf("%d", &num);
printf("Factors of %d are: ", num);
for (i = 1; i <= num; ++i) {
if (num % i == 0) {
printf("%d ", i);
}
}
return 0;
}
阅读全文