C Program to Print Factors of a Number using For Loop

C Program to Print Factors of a Number using For Loop

Write a Program to Print Factors of a Number using For Loop

// C Program to Print Factors of a Number using For Loop

#include <stdio.h>

int main()
{
    int n, i;

    printf("Enter a positive number :--> ");
    scanf("%d", &n);

    printf("Factors of %d are :--> ", n);

    for(i = 1; i <= n; i++)
    {
     	if (n % i == 0)
	 	{
            printf("%d ", i);
        }
	}
}

Output:

Enter a positive number :--> 80
Factors of 80 are :--> 1 2 4 5 8 10 16 20 40 80