0% found this document useful (0 votes)
36 views1 page

Area of Rectangle

The document explains how to calculate the area of a rectangle in C programming by inputting the length and width, multiplying them together, and outputting the result. It provides the area formula, logic steps, and a sample C program to find the area.

Uploaded by

Shanmuk_Ch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views1 page

Area of Rectangle

The document explains how to calculate the area of a rectangle in C programming by inputting the length and width, multiplying them together, and outputting the result. It provides the area formula, logic steps, and a sample C program to find the area.

Uploaded by

Shanmuk_Ch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Write a C program to input length and width of a rectangle and find area of the

given rectangle. How to calculate area of a rectangle in C programming. Logic to


find area of a rectangle whose length and width are given in C programming.

Example
Input
Enter length: 5
Enter width: 10
Output

Area of rectangle = 50 sq. units


Required knowledge
Arithmetic operators, Data types, Basic input/output

Area of rectangle
Area of a rectangle is given by the formula -

Area of rectangle formula


Where l is length and w is width of the rectangle.

Logic to find area of rectangle


Below is the step by step descriptive logic to find area of rectangle -

Input length and width of rectangle. Store it in two different variables say length
and width.
Apply formula to calculate rectangle area i.e. area = length * width.
Finally, print the value of area.
Program to find area of rectangle
/**
* C program to find area of rectangle
*/

#include <stdio.h>

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

/*
* Input length and width of rectangle
*/
printf("Enter length of rectangle: ");
scanf("%f", &length);
printf("Enter width of rectangle: ");
scanf("%d", &width);

/* Calculate area of rectangle */


area = length * width;

/* Print area of rectangle */


printf("Area of rectangle = %f sq. units ", area);

return 0;
}
Output
Enter length of rectangle: 5
Enter width of rectangle: 10
Area of rectangle = 50.000000 sq. units

You might also like