/* * bonus.c * FINAL * BY: John Stile * Purpose: Waht is the output generated by the program? * Explain how you reached your answer. * What it does: * * First: I think you ment int main(void) or it won't compile. * I had to add return 0 as well to make it compile. * Second: Initially x=6 * mystry recursively calls it self, * each time making x one less, until x=1, * z=6*5*4*3*2=720 * 720 is returned to main, and assigned to y. */ #include // include headers to functions in stdio library #include // include headers to functions in stdlib library int mystery(int); // prototype mystery: takes int, returns int int main(void) // header for main, takes nothing, returns nothing { int x=6; // declare and initialize int x = to 6 int y; // declare int y y=mystery(x); // call function mystry, passing value stored in x=6 // and assign return value to y printf("y=%d", y); // print decimal value of y return 0; } int mystery(int x) // header for funciton mystery, assign value passed to // local variable x { int z; // declare int z if( x==1 ) // if x contains 1, do block { return 1; // return 1 to calling function } z=mystery(x-1)*x; // subtract 1 from value in x // NOTE: since this is never 1 expression will never evalutate to zero // call function.... return z; }