Area and perimeter of a retangle

When I run it, I can input length and width.
It's not outputting the area and perimeter.
What am I missing?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  #include<iostream>

using namespace 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.
Thanks for the help
Topic archived. No new replies allowed.