/* Once we've got a counting function, it is easy to extend it to other purposes. This is our program for making centigrade to fahrenheit conversion tables */ #include "library.h" void convert_to_fahrenheit(double c) { print(c); print(" degrees C is "); print(c/5*9+32); print(" degrees F"); new_line(); } void count_from_to(double start, double end, double c) { if (start<=end) { if (c<=end) { convert_to_fahrenheit(c); count_from_to(start, end, c+1); } } else { if (c>=end) { convert_to_fahrenheit(c); count_from_to(start, end, c-1); } } } void main() { count_from_to(10, 30, 10); } /* At the very end of class I made an editing mistake. When I wanted to make it run from 19 to 21 in steps of 0.1, I changed to call in main to count_from_to(19, 21, 0.1); which was just careless. The 0.1 should have been 19. it is the c+1 and the c-1 in the function definition that should have been changed to c+0.1 and c-0.1 */