A divisor of an integer , also called a factor of , is an integer which divides 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