C Program to Print All Divisor of Number using While loop

C Program to Print All Divisor of Number using While loop

Write C Program to Print All Divisor of Number using While loop

//WAP to print all the divisors of a number

#include <stdio.h>

int main()
{
	int n;
	printf("Enter the number :--> ");
	scanf("%d", &n);

	int div = 2;  //divisor

	printf("All the divisors of %d are : ", n);
	while(div < n)
	{
		if(n % div == 0)
		{
			printf("%d ",div);
		}
		div++;
	}

	return 0;
}

Output:

Enter the number :--> 56
All the divisors of 56 are : 2 4 7 8 14 28