To print all the divisors of a given number
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int i, n;
clrscr();
printf("Enter the number : ");
scanf("%d", &n);
printf("\nThe divisors are :\n\n");
for(i = 1 ; i <= n ; i++)
if(n % i == 0)
printf("%d\t", i);
getch();
}
Output:
Enter the number : 15
The divisors are :
1 3 5 15
-
UpdatedDec 30, 2019
-
Views19,288
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order