// Week 3 Monday Lecture // Demonstrations of writing and using functions with different prototypes // It is good style to have prototypes at the top, in the order // they are used in the program. // Then have the actual implementations below main. #include // Function prototypes int maximum(int x, int y); void print_stars(int number_of_stars); void print_warning(void); int main(void) { int num = 7; // Store the return value in a variable to use later int max = maximum(10, num); print_stars(max); print_warning(); return 0; } // Given two integer inputs, x and y, // returns the larger of the two integers int maximum(int x, int y) { int max = x; if (x < y) { max = y; } // returns an int value return max; } // Given an int input, prints the specified number of stars // on a single line void print_stars(int number_of_stars) { int i = 0; while (i < number_of_stars) { printf("*"); i = i + 1; } printf("\n"); } // Prints a warning message void print_warning(void) { printf("#########################\n"); printf("Warning: Don't plagiarise\n"); printf("#########################\n"); }