To find the area of a rectangle or a square you need to multiply the length and the width of a rectangle or a square. There are different units for perimeter andarea The perimeter has the same units as the length of the sides of rectangle or square whereas thearea’s unit is squared.
In this example.I’ll show how to calculate Area and Perimeter of Rectangle in C++.
Source Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#include <iostream> #include<stdlib.h> using namespace std; int main() { int l,w,perimeter,area; cout<<"Length : "; cin>>l; cout<<"Width : "; cin>>w; area=l*w; perimeter=2*(l+w); cout<<"Area of Rectangle : "<<area<<endl; cout<<"Perimeter of Rectangle : "<<perimeter; } |
Output:
[…] Calculate Area and Perimeter of Rectangle in C++ […]