// file: $(ECE_1111)/labs/01/l01_03/myfuncts_00.cc // // revision history: // 20180724 (JP): initial version // // local include files // #include "myprog.h" // function: set_value // // arguments: // float value: the input value // // return: the value of the input // // This function simply returns the value of the argument. // float set_value(float value_a) { value_a = 10.0; return value_a * (float)2.0; } // function: set_value (by pointer) // // arguments: // float* value: the input value // // return: the value of the input // // This function simply returns the value of the argument. // float set_value(float* value_a) { *value_a = 10.0; return *value_a * (float)2.0; } // function: mymemory // // arguments: // char* buf: the input value // // return: nothing // void mymemory(char* buf) { buf = new char[999]; fprintf(stdout, "inside: buf = %u\n", buf); return; } // function: fact // // arguments: // long n: the operand // // return: the factorial of n // // This function simply returns the factorial of the argument. // long fact(long n_a) { /* // compute the factorial using a loop // long value = n_a; while (n_a > 2) { n_a--; value *= n_a; } // exit gracefully // return value; */ // compute the factorial recursively // if (n_a <= 1) // base case {return 1;} else {return n_a * fact(n_a - 1);} }