C++ Area and Perimeter of a Rectangle

#include <iostream>

// Function to calculate the area of a rectangle
double calculateArea(double length, double width) {
    return length * width;
}

// Function to calculate the perimeter of a rectangle
double calculatePerimeter(double length, double width) {
    return 2 * (length + width);
}

int main() {
    double length, width;

    std::cout << "Enter the length of the rectangle: ";
    std::cin >> length;

    std::cout << "Enter the width of the rectangle: ";
    std::cin >> width;

    double area = calculateArea(length, width);
    double perimeter = calculatePerimeter(length, width);

    std::cout << "Area of the rectangle: " << area << std::endl;
    std::cout << "Perimeter of the rectangle: " << perimeter << std::endl;

    return 0;
}

This C++ code calculates the area and perimeter of a rectangle. It defines two functions calculateArea and calculatePerimeter to compute the area and perimeter, respectively, based on the given length and width. In the main() function, it prompts the user to input the length and width of the rectangle, then calculates and displays the area and perimeter using the provided functions.