// This program reads "input" from an array and prints output // to the screen. When the input is even, mult2 is called to // multiply the argument sent to it by 2 (through repeated // addition). If the input is odd, mult3 is called to multiply // the value by 3. Execution stops when a 0 value is read. // The output is the value, followed by its product. #include int mult2 (int); int mult3 (int); int main () { int input [] = {5, 12, 75, 0}; int *index = input; int x; int num; x = *index; while (x != 0) { if ((x & 1) == 0) num = mult2 (x); else num = mult3 (x); printf ("0x%08x\n", x); printf ("0x%08x\n", num); index++; x = *index; } } int mult2 (int y) { int ret; ret = y; ret += y; return ret; } int mult3 (int z) { int ret; ret = z; ret += z; ret += z; return ret; }