Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this please!! I need help with this please Everything in C++ This lab assignment will help you to understand Polymorphism, functions

I need help with this please!! image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
I need help with this please
Everything in C++
This lab assignment will help you to understand Polymorphism, functions which return a value and the difference between reference and value parameters. Step 1: Laboratory Preparation Create a directory call 1 ab 6 inside your 2400/ Labs directory. Do your work in this new directory. Step 2: Polymorphism Polymorphism is another name for function overloading. As we discussed in class a program can have several functions with the same name. But each function must have different types or different numbers of formal parameters. For this part of the lab assignment, you need to figure out which function gets called and the order of the functions that gets called manually. The following program has nine functions that take different number and different types of parameters and calculate the sum of the numbers passed into the functions. \#include \#include using namespace std; // First sum int sum( int x, int y) // Second sum double sum(double x, double y ) // Third sum double sum(int x, double y ) // Fourth sum int sum( int x, int y, int z ) // Fifth sum double sum(double x, double y, double z ) // Sixth sum int sum(int a, int b, int c, int d ) // Seventh sum double sum (double a, double b, double c, double d) // Eighth sum double sum(int a, double b, int c, double d, int e, double f ) // Ninth sum double sum (double a, double b, double c, double d, double e, double f) // Seventh sum double sum(double a, double b, double c, double d) { return (sum(a, b) + sum(c, d)); \} // Eighth sum double sum(int a, double b, int c, double d, int e, double f) { return (sum(a, c, e) + sum (b,d,f)); \} // Ninth sum double sum(double a, double b, double c, double d, double e, double f) { return (sum(a, c, b, d) + sum(e, f)); \} Answer questions 1 - 5 on the answer sheet. Step 3: Parameter Passing First copy the find min. cc from /homeabukama/2400/1ab6 and place it in the 1 ab 6 directory. Then read and understand the program. Compile and run with many different sets of integer values. For example, enter list of numbers with the minimum value at middle, at the end etc. Answer questions 6 - 10 on the answer sheet. CS2400 Answer Sheet for Laboratory Assignment #6 Name/PID: Turn this sheet to your lab instructor at the end of the lab for grading. Step 2: Answer the following 5 questions by manually tracing the nine functions given in lab sheet. 1. (10 pts.) For the first cout statement, which sum is called? 2. (10 pts.) For the second cout statement, which sum is called? 3. (10 pts.) For the third cout statement, which functions are called? In this case, give the order that the functions are called as well. 4. (10 pts.) For the fourth cout statement, which functions are called? In this case, give the order that the functions are called as well. 5. ( 10 pts.) For the fifth cout statement, which functions are called? In this case, give the order that the functions are called as well. Step 3: For questions 6-9, make the changes and compile and run the program. 6. (10 pts) Explain what happens if you remove the s sign from the getkum function declaration (prototype) and the function heading. Don't forget to put the G back before moving on to the next question. 7. (10 pts) Similarly explain what happens if you remove the 6 from f indMin function declaration and the function heading. Don't forget to put the s back before moving on to the next question. 8. (10 pts) Explain what happens if you change the order of actual arguments in the function call findmin (minimum, number); to findMin(number, minimum); 9. (10 pts) Explain what happens if you remove the call to the function getNum (number) ; Comment (//) this statement out and run the program to find out the outcome. Make sure that vou remove the // before moving on to the next question (b) 9a. Before the while loop. 9b. Inside the while loop 10. ( 10 pts) Identify and write the names of value and/or reference parameters in the following functions. Write the word none if there are no value/reference parameters

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

Distinguish between job- order costing and process costing.

Answered: 1 week ago

Question

5. Why is the job done?

Answered: 1 week ago