#include<iostream>
usingnamespace std;
int main()
{
int length;
int width;
int area, perimeter;
cout << "Please enter the length: ";
cin >> length;
cout << "Please enter the width: ";
cin >> width;
perimeter = 2 * (length + width);
area = length * width;
cout << "The area is " << area << endl;
cout << "The perimeter is " << perimeter << endl;
return 0;
}
The program works correctly when I run it. It does close right after I press 'Enter' at the 'cin >> width;' statement, because you have nothing in the program to keep it open. Try placing a ' cin >> length;' at line 22 and the 'return 0' on line 23; That will keep the console from closing prematurely.