Mail Archives: djgpp/2001/06/22/12:36:46
----- Original Message -----
From: "Jyri Vahtera" <jyrva AT mbnet DOT fi>
Newsgroups: comp.os.msdos.djgpp
To: <djgpp AT delorie DOT com>
Sent: Thursday, June 21, 2001 5:58 AM
Subject: Problem in Factorial Program
> Here is code:
>
> #include <stdio.h>
> long factorial(n)
> int n;
>
> {
> long result = 1;
> while (n>1) { result = result*n; n = n - 1; }
> return result;
> }
>
> main()
> {
> }
>
> Where I put the main?
>
>
Hi!
I think i did not understand well your question, or what is wrong with your
code but here goes some
hints:
Put something like this in main:
printf("Enter a number:");
scanf("%d",&x);
printf("%d factorial is %d\n",x,factorial(x));
- Raw text -