Answers for "C++ Area of a Rectangle"

C++
1

C++ Area of a Rectangle

float length, width, area, perimeter;

    cout << "Input the length of a rectangle: ";
    cin >> length;
    cout << "Input the width of a rectangle: ";
    cin >> width;

    area = length * width;
    cout << "The area of a rectangle is " << area << endl;

    perimeter = length + length + width + width; // also >  2*(length + width)
    cout << "The perimeter of a rectangle is " << perimeter << endl;
Posted by: Guest on March-09-2022

Code answers related to "C++ Area of a Rectangle"

Browse Popular Code Answers by Language