Write a C Program to print out all of the factors of a number from 1 to N.
For N = 9, output is 1, 3, 9
For N = 7, output is 1, 7
code:
main()
{
int i=1,num;
printf("Enter num:");
scanf("%d",&num);
printf("%d ",i);
do
{
i++;
if(num%i==0)
{
printf("%d ",i);
}
return 0;
}
Program Output:
For more problems click here
No comments:
Post a Comment