#include "library.h" int formula(int x, int y) { return x*y; } // this is an absolutely trivial function, just an illustration. // a function can do anything. It allows an otherwise meaningless // formula to be given a meaningful name, and it allows a very // complicated formula to just be typed once but used many times // without risk of mistakes slipping in. void cajole(int a, int b) // a and b are just the names that this function uses to refer to // its inputs. They are meaningless outside the function { print("Obey me and I will allow "); print(a); print(" times "); print(b); print(" to remain "); const int answer = formula(a, b); // the values of a and b are given to "formula" // as its inputs. "formula" doesn't know or care // where its inputs came from. It just knows them // as x and y. if (answer % 10 == 2) print("forbidden.\n"); else if (answer >= 100) print("too big for you to worry about.\n"); else { print(answer); print(" for ever.\n"); } } void main() { print("Greetings, human!\n"); cajole(6, 9); // 6 and 9 are given as the inputs to "cajole", who refers // to them as a and b cajole(8, 9); cajole(12, 13); cajole(7, 9); cajole(1+2+3, 9+8+7); print("Get on with your work\n"); }