Expand|Select|Wrap|Line Numbers
- //declaring functions
- int GetLength();
- int GetWidth();
- int CalculateArea(int Length, int Width);
- int main()
- {
- int Length, Width, Area;
- //print functions
- Length=GetLength();
- Width=GetWidth();
- Area=CalculateArea(&Length, &Width);
- return 0;
- }
- //ask user for length, return as int
- int GetLength(int &Length)
- {
- cout << "What is the length of the room?" ;
- cin >> Length;
- while (Length <0)
- { cout << "Please enter a positive number." << endl;
- cin >> Length;
- }
- return Length;
- }
- //ask user for width, return as int
- int GetWidth(int &Width)
- {
- cout << "What is the width of the room?" ;
- cin >> Width;
- while (Width <0)
- { cout << "Please enter a positive number." << endl;
- cin >> Width;
- }
- return Width;
- }
- int CalculateArea(int Length, int Width)
- {
- int Area;
- Area=Length*Width;
- return (Area);
- }