// file: lecture_19/myfuncts_01.cc // // revision history: // // 20210302 (JP): refectored code // // local include files // #include "example.h" // function: mymemory // // arguments: // char* buf: the input value // // return: nothing // void mymemory(char* buf) { buf[0] = 'J'; buf[1] = 'o'; buf[2] = 'e'; buf[3] = (char)NULL; fprintf(stdout, "inside mymemory(): 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) { return 1; } else { return n_a * fact(n_a - 1); } } // function: mymatrix // // arguments: // float* x; // long ncols; // // return: bool // // This function simply returns the factorial of the argument. // bool mymatrix(float* x, long nrows, long ncols) { float mm[nrows][ncols]; long k = 0; for (long i = 0; i < nrows; i++) { for (long j = 0; j < ncols; j++) { x[k++] = i + j; mm[i][j] = i + j; } } return true; }