To find the perimeter of a square, just add up all the lengths of the sides.
The area of a square: To find the area of a square, multiply the lengths of two sides together. Another way to say this is to say “square the length of a side.
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 | #include <iostream> #include<stdlib.h> using namespace std; int main() { int s, area, perimeter; cout<<"Side : "; cin>>s; area = 4*s; perimeter = s*s; cout<<"Area of Square : "<<area<<endl; cout<<"Perimeter of Square : "<<perimeter; } |
Output:
it is a good experience with c++ program,