How to findout area of rectangle in C++
The length and breadth of a rectangle and radius of circle are input through the keyboard.Write a program to calculate the area and perimeter of the rectangle, and the area & circumference of the circle. Covered Area Problem is a classic algorithm problem used for academic teaching purposes. The basic idea is to give several pairs of Cartesian coordinates as the input. Each pair of coordinate represents the upper-left corner and lower-right corner of a rectangle. The goal of the system is to find out the total area covered by all those rectangles. Please note that we can not just add all the covered area of each rectangles since the rectangles can be overlapped each other in any order.
#include
#include
void main()
{
int l,b,r,area1,perimeter;
float area2,circum;
clrscr();
printf(“nEnter Length & Breadth of Rectangle”);
scanf(“%d%d”,&l;,&b;);
area1=l*b;
perimeter=2*l+2*b;
printf(“nArea of Rectangle=%d”,area1);
printf(“nPerimeter of Rectangle=%d”,perimeter);
printf(“nnEnter Radius of circle”);
scanf(“%d”,&r;);
area2=3.14*r*r*r;
circum=2*3.14*r;
printf(“nCircumference of circle=%f”,circum);
printf(“nnnnnnPress any key to exit…….”);
getch();
}
#include
void main()
{
int l,b,r,area1,perimeter;
float area2,circum;
clrscr();
printf(“nEnter Length & Breadth of Rectangle”);
scanf(“%d%d”,&l;,&b;);
area1=l*b;
perimeter=2*l+2*b;
printf(“nArea of Rectangle=%d”,area1);
printf(“nPerimeter of Rectangle=%d”,perimeter);
printf(“nnEnter Radius of circle”);
scanf(“%d”,&r;);
area2=3.14*r*r*r;
circum=2*3.14*r;
printf(“nCircumference of circle=%f”,circum);
printf(“nnnnnnPress any key to exit…….”);
getch();
}