Tuesday 30 April 2013

DIVISORS OF A NUMBER

divisor of an integer n, also called a factor of n, is an integer which divides n without leaving a remainder.

Here is a very simple C program to find all the divisors of a number inputted by the user.

/********************************************************************************/

#include<stdio.h>
#include<conio.h>

int main()
{
long num,i;
clrscr();
printf("ENTER A NUMBER : ");
scanf("%ld",&num);

for(i=1;i<=num;i++)
{
if(num%i==0)
{
printf("%ld\t",i);
}
}
getch();
return 1;
}
/*******************************************************************************/

No comments:

Post a Comment