I have written the program for factors of #'s 1-50 but the factors print out below the number being factored. I can't figure out how to make it all on the same line.
i.e. (now) divisors of 25 are
1
5
25
(need) divisors of 25 are 1, 5, 25.
here is my code;
[CODE=c]#include <stdio.h>
int main()
{
int i;
int x=50;
int j;
int k=50;
for (i=1; i<=x; i++)
{ printf("The divisors of %d are ",i);
for (j=1; j<=k; j++)
if(i%j==0)
printf("%d",j);
}
}[/CODE]
i.e. (now) divisors of 25 are
1
5
25
(need) divisors of 25 are 1, 5, 25.
here is my code;
[CODE=c]#include <stdio.h>
int main()
{
int i;
int x=50;
int j;
int k=50;
for (i=1; i<=x; i++)
{ printf("The divisors of %d are ",i);
for (j=1; j<=k; j++)
if(i%j==0)
printf("%d",j);
}
}[/CODE]
Comment