English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

3 answers

void factor(int n)
{
for(i=1;i<=n;i++)
{
if((n%i)==0)
printf("%d",i);
}
}

it wld be bettr to write this in the main function or wherever it is needed rather than declaring a seperate function lik above if its affordabl.

2007-03-15 01:41:25 · answer #1 · answered by freeze 2 · 0 0

It's not the most efficient way, but this function should print out all the factors of n.

void printfactors(double n)
{
for (double i = 1; i <= n; i++)
{
if (n / i == floor(n / i))
printf("%f\n, i);
}
}

2007-03-15 00:18:55 · answer #2 · answered by Groucho Returns 5 · 0 0

#include
#include

void main()
{
int number, fact,x,y;

clrscr();

printf("Give a number");

scanf("%d",&number);

for(x=1;x<(number/2);x++)
{
if(number%x==0)
{ printf("%d\n",x);
}
}

getch();
}

Type it as it is to get the results.

Good Luck!

2007-03-16 00:57:21 · answer #3 · answered by cool_chunks 3 · 0 0

fedest.com, questions and answers