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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started