****************************************
* LUG meet on 12 Jan. 2003 @ VJTI
****************************************
> > int fact;
> > int x;
> > fact=factorial(6);
> > printf ("%i\n",fff());
> > }
> >
> >
> > int factorial(int x){
> > if(x>1) return(x*factorial(x-1));
> > }
> >
> > int fff () {
> > ;
> > }
> >
OK I give up, what do you mean by the fff() function?
>
>
>
> Something very strage, I did the following (inserted wait(1),
> thats it)
>
> # include <stdio.h>
> main(){
> int fact;
> int x;
> fact=factorial(6);
> wait(1);
> printf ("%i\n",fff());
> }
You've defined fff() as int, and it _doesn't_ return anything, plus you are
printing the value it returns (the printf statement)!
If you are really interested in the factorial of 6, I guess you should be
printing the return value of factorial(6).
That is your printf statement should look something like this:
printf("%d\n", factorial(6)); or simply printf("%d\n", fact);
Also, the int x declaration in main() is superfluous - you can do without
it; and as a good programming practice never choose variable names that
collide. Your main() has an x, and so does your factorial() - they are
different and don't mean the same x.
Warm wishes,
Amol Hatwar
--
_______________________________________________
http://mm.ilug-bom.org.in/mailman/listinfo/linuxers