Program to Find Area and Perimeter of Rectangle

Algorithm

Step 1: Start

Step 2: Declare integer variables l, w, a, p

Step 3: Take input for length (l) and width (w)

Step 4: Compute area as a = l * w

Step 5: Compute perimeter as p = 2 * (l + w)

Step 6: Print the values of area and perimeter

Step 7: End

Flowchart

graph TD; A([Start]) --> B[Declare int l, w, a, p]; B --> C[/Input l, w/]; C --> D["Compute a = (l * w)"]; D --> E[Print a]; E --> F["Compute p = 2 * (l + w)"]; F --> G[Print p]; G --> H([End]); classDef start fill:#00cc44,stroke:#006622,stroke-width:2px,color:#ffffff; classDef stop fill:#ff4444,stroke:#cc0000,stroke-width:2px,color:#ffffff; classDef input_output fill:#ffdd44,stroke:#cc9900,stroke-width:2px,color:#000000; classDef process fill:#4488ff,stroke:#0044cc,stroke-width:2px,color:#ffffff; class A start; class H stop; class C,E,G input_output; class B,D,F process;

Program

#include<stdio.h>

int main()
{
    int l, w, a, p;
    printf("Enter length: ");
    scanf("%d", &l);

    printf("Enter width: ");
    scanf("%d", &w);

    // Area
    a = l * w;
    printf("Area of Rectangle: %d", a);

    // Perimeter
    p = 2 * (l + w);
    printf("\nPerimeter is: %d", p);

    return 0;
}
                

Test Case Output
Enter length: 5
Enter width: 3

Area of Rectangle: 15
Perimeter is: 16