Homework 3 ENEE 114 Spring 2007 POSTED: See below for the posted date of each problem DUE: 11:59 pm Sunday April 15 * name your answers as hw3.1.c, hw3.2.c, ..., and submit each of them via the GLUE submit command * make sure that you document each hw3.x.c file /****************************************************************************/ 1. (posted: Tue Mar 27) complete the following code so it will ask the user to enter the radius and whether to compute the area or the circumference or both of a circle. #include float area(float); // a function that takes the radius of a circle as input and returns its area float circumference(float); // a function that takes the radius of a circle and returns its circumference int main(void) { float r; int i; printf("Enter the radius of the circle (positive number):"); scanf("%f", &r); printf("Enter your choice: 0 for area, 1 for circumference, 2 for both:"); scanf("%d", &i); switch(i) { case 0: printf("Area = %f\n", area(r)); break; case 1: printf("Circumference = %f\n", circumference(r)); break; case 2: printf("Area = %f, Circumference = %f\n", area(r), circumference(r)); break; default: printf("Invalid choice.\n"); } return 0; } 2. (posted: Tue Mar 27) Write a recursive function to calculate n!! (for integer n > 1), which is defined as follows: n!! = n * (n-2) * (n-4) * ... 4 * 2 if n is even n!! = n * (n-2) * (n-4) * ... 3 * 1 if n is odd 2!! = 2 1!! = 1 3. (posted: Thu Mar 29) Modify the hanoi.c (or hanoi2.c) program posted on the course web site so it prints out the number of disks on each stick/peg after each move. For example, when there are 2 disks, your output should look like: 1: Move disk from A to B 1 disks on A; 1 disks on B; 0 disks on C. 2: Move disk from A to C 0 disks on A; 1 disks on B; 1 disks on C. 3: Move disk from B to C 0 disks on A; 0 disks on B; 2 disks on C. 4. (posted: Sat Apr 7) Write a program to read in a number in digit form and print it out in "word" form. For example, on input "2078", prints out "two zero seven eight". Read in the number character by character or as a string (array of char). 5. (posted: Sat Apr 7) The cells in a 10x10 grid are labeled 1, 2, ..., 100. 1 to 10 are on the first row, from left to right; 11 to 20 are on the second row, from left to right; and so on. Write a C program that reads in two integers between 1 and 100, and prints out the labels in the grid that are in the rectangle with the two input integers as the two diagonal corners. For example, on input 1 and 23, output 1, 2, 3, 11, 12, 13, 21, 22, 23 on input 15 and 4, output 4, 5, 14, 15 on input 4 and 23, output 3, 4, 13, 14, 23, 24 on input 95 and 99, output 95, 96, 97, 98, 99 on input 3 and 43, output 3, 13, 23, 33, 43