having a problem with a FOR statement
This is a project I have for school. I am asking for help with my homework. I keep getting 39 as the answer to this program. The program is supposed to be Factorial, meaning that when you enter in an integer it will multiply itself and then by its decremented self for example 3!=3*2*1 ==6. Well i think I have the FOR statement right but it keeps giving me the wrong answers. Here is the code I have got.
#include <stdio.h>
int fact(int d);
void print_out (int d);
void main (void)
{
int b,y;
printf("enter a positive integer:\n");
scanf("%d",&b);
y=fact(b);
print_out(y);
}
int fact(int d) //
{
int c,a;
for(d=c;d>1;--d)
{
a=c*d;
}
return(a);
}
void print_out (int d)
{
printf("After the Factorial the number is:%d",d);
}
this is my problem