Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!