Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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;
 
PREVIOUS NEXT
Tagged: #Area #Rectangle
ADD COMMENT
Topic
Name
1+7 =