/* * Project3.functions.c * Chapter 8 * By John Stile */ #include #include #include "Project3.headers.h" //////////////////////////////////////////// int input_number(void) // header for input_number, takes nothing, returns int { printf(" Enter Function: int input_number(void)\n"); float zz; // declare float do // execute bock before evaluating while { printf("integer: "); // prompt for input scanf("%f", &zz); // read float from stdin getchar(); // clear input buffer } while ( ( (int)zz != zz) && printf("Not and Int.\n Enter an ") ); // keep asking while zz is not an int // print warning as well return ((int)zz); } //////////////////////////////////////////// void print_result( int ll, int mm, int pp ) { printf(" Enter Function: void print_result( int ll, int mm, int pp )\n"); printf("%d to the %d = %d\n", ll, mm, pp); // print result } //////////////////////////////////////////// // 2 Additional functions //////////////////////////////////////////// int my_rand(int ll) // take an int { printf(" Enter Function: int my_rand(int ll)\n"); srand(ll); // seed rand with value at ll return( rand() ); // return a random int to calling function } //////////////////////////////////////////// void print_sequence(int ll) { printf(" Enter Function: void print_sequence(int ll)\n"); int ii; printf("Printing sequence from 0 to %d\n"); // print info about function for(ii=0; ii<=ll; ii+=1 ) // initialize ii to zero // if value of ii is less than or equal to value of ii // do block // increment ii by one { printf("%d\t", ii); // print decimal value of ii } printf("\n"); // add a newline at the end of the sequence }