Please write a C++ program that will accept 3 integer numbers from the user, and then output these 3 numbers in ascending order, their sum, and their average. You must stop your program when the first number from the user is -999. Program Design Specifications and Regulations:
(1) You must use your full name on your welcome and thank-you messages.
(2) You must specify 3 prototypes in your program (before main( ) ) for 3 functions as follows: int max(int p, int q, int r); // prototype to return maximum of p, q, r int min(int p, int q, int r); // prototype to return minimum of p, q, r int mid(int p, int q, int r); // prototype to return middle of p, q, r
(3) You must define the above three integer functions properly in your program after main( ). If you define those three functions before main( ), you should not specify those 3 prototypes.
(4) You must NOT use any C++ existing or pre-defined functions in your program.
(5) You must fully test your program to make sure that these three functions are working perfectly for any 3 numbers in any sequence.
(6) How to show those 3 numbers (p, q, r) in ascending order without sorting them at all? The answer is that you show their minimum number, middle number, and maximum number.
(7) How to check and detect that q is the middle number among p, q, and r?
The answer is that you need to consider two cases as follows:
if (q >= p && q <= r) return q ; // case 1: r, q , p i.e., r <= q <= p
if (q >= r && q <= p) return q ; // case 2: p, q, r i.e., p <= q <= r ===========================================================================.
Your test case #1 must look exactly like the output in the picture, including the data. You must also do test case #2 and test case #3 with different sets of data to prove that your program is working perfectly for any data. Each test case or test run must begin with a welcome message, and must end with a thank-you message.
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 3 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_forwardInstructions: For each Exercise below, write your code in an IDE and run your code within the IDE as well. Once you have satisfied the Exercise requirements, paste your code below under the corresponding Exercise. Exercise 1: Please perform in C++ Write a program using a function which will accept two integers as an argument and return sum. Call this function from the main function and print the results in the main function! This is a nice and easy warm up to functions! ● ●arrow_forward2. Please provide the correct C++ code compatible with Visual Studio for the following question:arrow_forward
- Create a function in C language that takes two integers x, and y as the parameters and returns the sum and the absolute difference of both the numbers but the return type of the function should be void. You can add extra parameters to the function but the function should not return anything and should send the required values as well. Test your function for the numbers 10, and 5 inside the main function.arrow_forwardWrite the following in C++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