delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/06/22/12:36:46

Message-ID: <011201c0fb39$1457a610$4601a8c0@wladeira>
From: =?iso-8859-1?Q?Andr=E9_Ladeira?= <ladeira AT automatos DOT com>
To: <djgpp AT delorie DOT com>
References: <9gsd0l$34e$1 AT news DOT clinet DOT fi>
Subject: Re: Problem in Factorial Program
Date: Fri, 22 Jun 2001 13:33:33 -0300
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Reply-To: djgpp AT delorie DOT com

----- 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019