Functions,factorials asap help needed! :(
Hi there!
I have to make c porgram, that finds factorial of number. Using defined function find and print factorials for whole numbers from 1 to n, up to the maximum possible integer value.
Hope for some help! :)
Here's my try, but i dont know how ti make it with my own fuctions:
Code:
#include<stdio.h>
int main(){
long f=1;
int i,num,min=0,max;
printf("Type n: ");
scanf("%d",&max);
printf("Factorial 1-n: ");
for(num=min;num<=max;num++){
f=1;
for(i=1;i<=num;i++)
f=f*i;
printf("%ld ",f);
}
return 0;
}
you already have your own defined function
Just rename main() ...
Code:
int my_defined_function(){
/* YOUR EXACT CODE AS ABOVE */
}
and add a different main that calls your function
Code:
int main(void) {
my_defined_function();
return 0;
}