0
I am studying functions by passing parameter,the teacher asked to calculate the factorial of a number by passing parameter,the maximum that I got was the code below, yet the code does not execute.
#include <stdio.h>
#include <stdlib.h>
void fatorial(int num, long int*fat);
int main()
{
int num;
printf("Digite um numero:\n");
scanf("%d", &num);
fatorial(num);
return 0;
}
void fatorial(int num, long int *fat)
{
for(fat = 1; num > 0; num = num - 1)
{
fat *= num;
}
printf("%ld\n", fat);
}
The compile code. I can see it here by just tapping my eye. " Calculate the factorial of a number per parameter passage" is a meaningless phrase, better formulate
– Jefferson Quesado
What do you mean by "calculate ... by passing parameter" ? Is the number to be calculated the only parameter of the function ? The factorial result is supposed to be assigned in a parameter (pointer) ?
– Isac