For your term project, you must do FOUR of the five problems listed below. Each program is smaller than most of your homework assignments, but you will not be given any hints or skeletons as with the homeworks.
The project is worth 10% of your term mark. It will be marked out of 100 points. Each program is worth 25 points. For extra credit, you may do all five programs and earn up to 25 extra points towards your 1000 point semester total.
Make sure your code is commented well and is readable, i.e., that it is indented properly (follow my style in lectures or the style in the textbook). MAKE SURE YOU HAVE A HEADER COMMENT AT THE TOP OF EACH PROGRAM, WHICH INCLUDES YOUR NAME. Also put header comments at the beginning of each function.
The project is due on the last day of class (8 December). Some of the skills needed will be discussed in class up until the last week of classes. However, you are STRONGLY encouraged to begin working on the project sooner rather than later, doing the parts you can do now.
As usual, submit your program electronically.
You should deposit your files in the professor's folder, named (e.g.)
Bring a hardcopy to class. PRINT EACH PROGRAM ON A SEPARATE PAGE. Please staple loose sheets together.
1. (25 points) The greatest common divisor of integers x and y is the largest integer that evenly divides both x and y. Write a recursive function gcd which determines the greatest common divisor of x and y. The gcd of x and y is defined recursively as follows. If y is equal to 0, then gcd(x,y) is x; otherwise gcd(x,y) is gcd(y,x%y), where % is the modulus operator. Write a program that asks the user to enter values for x and y and then calls gcd(x,y) and prints out the result.
2. (25 points) Write a program that will determine if an input string is a palindrome. A palindrome is a series of characters that is the same backwards and forwards. For example, "a man, a plan, a canal panama". Declare the input string as follows:
char buf;Use two pointers, declared as follows:
char *p1, *p2;each starting at opposite ends of the input string. Use pointer arithmetic to increment p1 and decrement p2, comparing characters until a mismatch is found (indicating that the input is not a palindrome) or the pointers meet (indicating that the input is a palindrome). Ignore spaces and punctuation marks and only compare letters.
3. (25 points) Write a program that reads strings from the keyboard and outputs them and their length. The program should keep reading strings and outputting them (and their length), until the user enters the sentinal word "quit", at which point the program should stop. Your program should be able to handle both upper and lower case words, as well as words with mixed case. Only an exact match (all lower case) "quit" should cause the program to stop.
4. (25 points) Write a program that asks the user to enter the date in three inputs, as follows:
Month DD, YYYY = NNNFor example:
January 1, 2000 = 001Note that you have to check for leap year, which is defined to occur in years divisible by 4 and not by 100, except it does occur in years divisible by 400. Also note that the day of month is formatted without leading zeros, but the day of year does have leading zeros.
5. (25 points) Define a structure called PERSON that contains the following fields: