C Language program to calculate rectangle area and circumference
Following program shows you how to calculate rectangle area and circumference.
This program gets rectangle length and width from user and calculates area and circumference and prints them using following formulas
Area = length X width
Circumference = 2 X length + 2 X width
#include <stdio.h>
int main(void) {
float rectangleLength;
float rectangleWidth;
printf("Enter length of rectangle:");
scanf("%f", &rectangleLength);
printf("Enter width of rectangle:");
scanf("%f", &rectangleWidth);
float areaOfRectangle = rectangleLength * rectangleWidth;
printf("Area of rectangle is: %f \n", areaOfRectangle);
float circumferenceOfRectangle =
2 * (rectangleLength) + 2 * (rectangleWidth);
printf("Circumference of rectangle is: %f", circumferenceOfRectangle);
}
Output:
Enter length of rectangle: 25
Enter width of rectangle: 42
Area of rectangle is: 1050.000000
Circumference of rectangle is: 134.000000