Area of Rectangle
To calculate the area of the rectangle we must know the formula area of rectangle=Length*Breadth.
To perform this operation in the c language first take the three variables like length, breadth, and area to display or store the final answer. Then take the input from the user using scanf, then store that values in length and breadth as shown in the code. Pass these variables in formulae to calculate the area of the rectangle. Then the answer is stored in area variable, display area. Refer the following code to calculate the area of the rectangle.
C language code to calculate area of Rectangle:
#include<stdio.h>
#include<conio.h>
void main()
{
int length, breadth, area;
clrscr();
printf("\nEnter the Length of Rectangle:");
scanf("%d",&length); //to accept length of rectangle
printf("\nEnter the Breadth of Rectangle:");
scanf("%d",&breadth); //to accept breadth of rectangle
area=length*breadth; //formula to find area of rectangle
printf("\nArea of Rectangle:%d",area);//display area
getch();
}
--------------------------------------------------------------------------------------
Output:
Enter the Length of Rectangle:6
Enter the Breadth of Rectangle:7
Area of Rectangle:42
Area of Rectangle
Reviewed by Amit Waghmare
on
June 21, 2019
Rating:
No comments: