/* main.c Started by Jeff Ondich on 1/3/96 Last modified 4/1/97 This main program is intended to be compiled together with factorial.c (and the header file factorial.h). 1. Read main.c. Without looking at factorial.c, what do you expect the full program to do? 2. Read factorial.h. This is a "header" file, and contains the interface to my ultra-tiny "factorial library." After reading factorial.h, a programmer should be able to use the factorial library without looking at the implementation in factorial.c. 3. Read factorial.c. This is the implementation of the factorial library. Questions about the code? Ask them. Notice how function return types and parameter lists are specified in C as opposed to Pascal. Compile the full program like so: cc -Wall -o factorial main.c factorial.c Did it compile? Did it run? Did it do what you expected it to do? 4. Leave out the #include "factorial.h" from main.c and recompile. What do you expect? Were you right? */ #include #include "factorial.h" void main( void ) { int theNumber, fact; printf( "Please enter a number: " ); scanf( "%d", &theNumber ); fact = factorial(theNumber); if( theNumber < 0 ) printf( "Negative numbers don't have factorials.\n" ); else if( fact <= 0 ) printf( "%d is too big\n", theNumber ); else printf( "%d! = %d\n", theNumber, fact ); }