C Program to Print All Divisors of Number using For Loop
Write a Program to Print All Divisors of Number using For Loop
// C Program to Print All Divisors of Number using For Loop #include <stdio.h> int main() { int n, div; printf("Enter the number :--> "); scanf("%d", &n); printf("All the divisors of %d are : ", n); for(div = 2; div < n; div++) { if(n % div == 0) { printf("%d ",div); } } return 0; }
Output:
Enter the number :--> 56
All the divisors of 56 are : 2 4 7 8 14 28