Question: Find two syntax errors in the following program: #include using namespace std; int area(int length, int width = 0); int main() { int length, width;
Find two syntax errors in the following program: #include using namespace std; int area(int length, int width = 0); int main() { int length, width; // for rectangle use both arguments cout << "Enter length and width of a rectangle" << endl; cin >> length >> width; cout << "The area is " << area(length, width) << endl; // for square, only need first argument cout << "Enter side of a square" << endl; cin >> length; cout << "The area is " << area(length) << endl; return 0; } int area(int length, int width = 0); { if ( width == 0 ) return length * length; return length * width; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
