Problem:
Write a program to calculate area and perimeter of a rectangle.
Solution:
#include<iostream>
#include<conio.h>
using namespace std;
int main ()
{
float a,p,l=8,w=9;
p=2*(l+w);
a=l*w;
cout<<"the area of rectangle is:"<<a<<endl<<"the perimeter of rectangle is:"<<p<<endl;
getch();
}
#include<conio.h>
using namespace std;
int main ()
{
float a,p,l=8,w=9;
p=2*(l+w);
a=l*w;
cout<<"the area of rectangle is:"<<a<<endl<<"the perimeter of rectangle is:"<<p<<endl;
getch();
}
Output:
Let me know in the comment section if you have any question.
Previous Post:
Program to calculate area and volume of a cylinder.