
Write a program using C++ that has two functions with the same name (function overloading) to calculate the area of different shapes.
- The first function takes the radius of a circle as input and returns the area of the circle.
- The second function takes the length and width of a rectangle as input and returns the area of the rectangle.
Your main function should declare three variables, one for the radius of a circle and two for the length and width of a rectangle, respectively. Initialize the variables with the following values:
double radius = 5.0;
double length = 10.0;
double width = 8.0;
Your program should call both functions with the respective input values and print the results to the console in the following format:
The area of the circle with radius [radius] is: [area]
The area of the rectangle with length [length] and width [width] is: [area]
You can assume that the value of radius is non-negative and the values of length and width are positive.
// Function to calculate the area of a circle given its radiusdouble calculateArea(double radius);
// Function to calculate the area of a rectangle given its length and widthdouble calculateArea(double length, double width);
SAMPLE OUTPUT:
The area of the circle with radius 5 is: 78.5398
The area of the rectangle with length 10 and width 8 is: 80

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- Which statement of the following is the most appropriate? Group of answer choices One good method for specifying what a function is supposed to do is to provide a precondition and postcondition for the function. One good method for specifying what a function is supposed to do is to provide a precondition and postcondition for the function. These form a contract between the programmer who uses the function and the programmer who writes the function. Using the assert function to check preconditions can significantly reduce debugging time, and the assertion-checking can later be turned off if program speed is a consideration. One good method for specifying what a function is supposed to do is to provide a precondition and postcondition for the function. These form a contract between the programmer who uses the function and the programmer who writes the function. Using the assert function to check preconditions can significantly reduce debugging time, and the…arrow_forward*DONOT USE CHATGPT, please put comments so i can understand. It’s a C language program with algorithm.arrow_forwardWrite a complete C++ program that helps the teacher to calculate the result of students in the test of Programming Technique. The program should perform the following tasks: Task 1: Write a function named getInput. a) This is a non-returning function. b) It takes the score of question 1, score of question 2, and score of question 3 as input parameters. c) The function should ask the user to enter the score (per 100) for each question. It sends all the values entered by the user in (c) back to the calling module through the use of reference parameters. d)arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





