here is the question: Write a program that accepts a positive integer. Use a function to calculate the factorial of
that number.
my codes:
#include <stdio.h>
#include <stdlib.h>
int fun(int z);
int main()
{
int n,x,fact;
printf("enter a number: ");
scanf("%d",&n);
fact=fun(n);
printf("factorial of %d is %ld\n" ,n,fact);
system("pause");
return(0);
}
int fun(int z)
{
int n,c, fact=1;
for(c=1;c<=n;c++)
return fact*c;
}
i am still having the difficulty when i enter 2 i should have get 2 but instead i get a 1. what is wrong?