Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2) Write a main function that does the following . Prompt the user to enter the size of the array and read the size entered
2) Write a main function that does the following . Prompt the user to enter the size of the array and read the size entered by the user . Declare a variable-length array of integers (int) of the size entered by the user . Seed the random number generator using current time .Prompt the user to enter maximum possible value for array elements (max) .Fill the array with random numbers between 1 and max (inclusive) .Print the array Call the shiftLeft function .Print the array again Note: you may reuse your fillArray and neatPrint functions from Lab 3 if you like Part 2 (Calculating Circle Circumference, Circle Area or Sphere Volume Using Function Pointers) Create a text-based, menu-driven program that allows the user to choose whether to calculate the circumference of a circle, the area of a circle or the volume of a sphere. The program should then input a radius from the user, perform the appropriate calculation and display the result. Use an array of function pointers in which each pointer represents a function that returns void and receives a double parameter. The corresponding functions should each display messages indicating which calculation was performed, the value of the radius and the result of the calculation. Use the constant value 3.14159 for . Call the program part2. c Use the code in Fiqure 7.28 of the book (Demonstrating an array of pointers to functions) as a model Use the while loop to process the user's choice (as in Figure 7.28). When the user enters 0, the circumference of a circle should be computed. When the user enters 1, the area of a circle should be computed. When the user enters 2, the volume of a sphere should be computed. When the user enters 3, the program should terminate Sample run of the program may look like the following Enter 0 for circumference, 1 for area, 2 for volume, 3 to end: 1 Please enter radius 2 The area of a circle is computed. Radius: 2.000000 Area: 12.566360 Enter 0 for circumference, 1 for area, 2 for volume, 3 to end: 0 Please enter radius: 1 The circumference of a circle is computed. Radius: 1.000000 Circumference: 6.283180 Enter 0 for circumference, 1 for area, 2 for volume, 3 to end: 2 Please enter radius: 3 The volume of a sphere is computed Radius: 3.000000 Volume: 113.097240 Enter 0 for circumference, 1 for area, 2 for volume, 3 to end: 3 Program execution completed Part 3 (Telephone-Number Word Generator) Standard telephone keypads contain the digits 0 through 9. The numbers 2 through 9 each have three letters associated with them, as is indicated by the following table Digit 2 Letter A BC DE F G HI JKL Digit Letter M N O PRS TUV WXY 7 4 (Note: to make it simpler, there is no 'Q' in the table) Many people find it difficult to memorize phone numbers, so they use the correspondence between digits and letters to develop seven-letter words that correspond to their phone numbers. For example, a person whose telephone number is 686-2377 might use the correspondence indicated in the above table to develop the seven- letter word "NUMBERS." Businesses frequently attempt to get telephone numbers that are easy for their clients to remember. If a business can advertise a simple word for its customers to dial, then, no doubt, the business will receive a few more calls Each seven-letter word corresponds to exactly one seven-digit telephone number. The restaurant wishing to increase its take-home business could surely do so with the number 825-3688 (i.e., "TAKEOUT) Each seven-digit phone number corresponds to many separate seven-letter words. Unfortunately, most of these represent unrecognizable juxtapositions of letters. It is possible, however, that the owner of a barber shop would be pleased to know that the shop's telephone number, 424-7288, corresponds to "HAIRCUT." The owner of a liquor store would, no doubt, be delighted to find that the store's telephone number, 233-7226, corresponds to "BEERCAN." A veterinarian with the phone number 738-2273 would be pleased to know that the number corresponds to the letters "PETCARE." Write a C program that, given a seven-digit number, writes to a file (called word.txt) every possible seven-letter word corresponding to that number. Each word should be written on a new line. There are 2187 (3 to the seventh power) such words. There should be 2187 lines in the file. Avoid phone numbers with the digits 0 and 1. Call the program part2.d Represent letters corresponding to digits as an array of strings char *phoneLetters [10] {" "ABC", "MNO", "PRS", "TUV", "WXY"); ", " ", "DEF", "GHI", "JKL", = Use array phoneLetters to get letters corresponding to digits. For instance, letters corresponding to digit 4 are phoneLetters [4] [0], phoneLetters [4] [1] , and phoneLetters [4] [2] . You may use 7 nested loops to generate all possible seven-letter words (one loop per digit in the number) Your program should do the following Represent letters corresponding to digits as an array of strings as shown above Prompt the user to enter a seven-digit phone number using the digits 2 through 9 Read the number entered by the user. Writes to a file called word.txt every possible seven-letter word corresponding to that number
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started