Question

Write a program that prompts the user to input the length and the width of a rectangle and outputs the area and circumference of the rectangle. The formula is

Area = Length x Width
Circumference = 2 x ( Length + Width)

Source Code

#include <stdio.h>

int main()
{
    int length, width, area, circumference;

    printf("Enter the length of the rectangle :");
    scanf("%d", &length);
    printf("Enter the width of the rectangle :");
    scanf("%d", &width);

    area = length * width;
    circumference = 2 *(length + width);

    printf("\nThe area of the rectangle is %d.", area);
    printf("\nThe circumference of the rectangle is %d.", circumference);

    return 0;
}

Output

Enter the length of the rectangle :15
Enter the width of the rectangle :9

The area of the rectangle is 135.
The circumference of the rectangle is 48.