The code below shows the factors of the number being input:
#include <stdio.h>
#include <stdlib.h>
void factorer(int x);
void factorer2(int x);
int main()
{
int number;
printf("Find factors of: ");
scanf("%d", &number );
void factorer(int x){
int number;
int dividend;
dividend = x;
for(number=1; number<=x; number++){
if(dividend % number == 0){
printf("%dn", number);
}
}
}
void factorer2(int x){
int number;
int dividend;
dividend = x;
for(number = x; number > 0; number--){
if(dividend % number == 0){
printf("%dn", number);
}
}
}
example if 10 is the input number, the output would be
1
2
5
10
10
5
2
1
but the output that i want is something that goes like
1 x 10
2 x 5
5 x 2
10 x 1
I know calling void functions are not possible in printf() so how might I be able to make this possible?
- - , .
برچسب:
نویسنده: استخدام کار