Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question text Find the errors in the following program. You must use pass by reference. #include using namespace std; void area2(int area, int length, int

Question text Find the errors in the following program. You must use pass by reference. #include using namespace std; void area2(int area, int length, int width = 0); int main() { int length, width, area; // for rectangle use two arguments cout << "Enter length and width of a rectangle" << endl; cin >> length >> width; cout << "The area is " << area2(area, length, width) << endl; // for squares use one argument cout << "Enter side of a square" << endl; cin >> length; cout << "The area is " << area2(area, length) << endl; return 0; } void area2(int area, int length, int width) { if ( width == 0 ) area = length * length; else area = length * width; }

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

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions