/ ************************************************************************** * * Purpose: generate the factorial of a number by iteration. * Author: M. J. Leslie * Date: 09-Apr-94 * **************************************************************************/ #include <stdio.h> int factorial(int num); main() { int num; puts ("This program will return the factorial of a number."); printf("Please enter the number ==> " ); scanf("%d", &num); printf(" %d! is %d\n",num, factorial(num) ); } int factorial(int num) { int count, ans=1; for (count=1 ; count <= num; count++ ) ans *= count; return ans; }
file: /Techref/language/ccpp/Cref/EXAMPLES/fact1.c, 0KB, , updated: 1997/4/21 09:52, local time: 2025/4/22 19:45,
160.79.110.211,10-1-162-97:LOG IN
|
©2025 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/TECHREF/language/ccpp/Cref/EXAMPLES/fact1.c"> language ccpp Cref EXAMPLES fact1</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Ashley Roll has put together a really nice little unit here. Leave off the MAX232 and keep these handy for the few times you need true RS232! |
.