C Program to Print Factors of a Number using While Loop
Write C Program to Print Factors of a Number using While Loop
//Write C Program to Print Factors of a Number using While Loop #include <stdio.h> int main() { int n, i; printf("Enter a positive number :--> "); scanf("%d", &n); printf("Factors of %d are :--> ", n); i = 1; while(i <= n) { if (n % i == 0) { printf("%d ", i); } i++; } }
Output:
Enter a positive number :--> 80
Factors of 80 are :--> 1 2 4 5 8 10 16 20 40 80