Saturday 14 March 2015

To print all the divisors of a given number Using C

# 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() ;
}


RUN 1 :
~~~~~~~
Enter the number : 15
The divisors are :
1 3 5 15

No comments:

Post a Comment