/ ************************************************************************** * * Purpose: Give the exponent of a number. * Author: M. J. Leslie * Date: 05-Apr-94 * **************************************************************************/ #include <stdio.h> int exponent(int); main(int argc,char *argv[]) { int user_val; char *progname; progname=argv[0]; /* have we got one command line parameter? */ if (argc != 2) { printf("%s syntax is:\n", progname); printf("\t%s num - where num is the number you ", progname); printf("require the exponent of.\n"); exit(); } /* y. Put it in a suitable variable */ user_val = atoi(argv[1]); /* get and O/P its exponent. */ printf(" The exponent of %d is %d \n", user_val, exponent(user_val)); } /************************************************************************ Get the exponent of an integer number. *************************************************************************/ int exponent(int input) { int count, result=1; /* 'result *= count' means 'result = result * count' to fortran programmers... */ for(count=1; count<=input; count++) result *= count; return result; }
file: /Techref/language/ccpp/Cref/EXAMPLES/exponent.c, 1KB, , updated: 1998/1/27 10:16, local time: 2024/8/22 23:10,
3.149.252.207:LOG IN
|
©2024 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://piclist.com/tecHREF/language/ccpp/Cref/EXAMPLES/exponent.c"> language ccpp Cref EXAMPLES exponent</A> |
Did you find what you needed? |
![]() o List host: MIT, Site host massmind.org, Top posters @none found - Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr. |
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! |
.