A Program to Find the Area of a Square
In this example, we are giving a program to find the area of a square. The rule of finding the area of a square is: A = length * length.
Program to find the area of a square:
#include <iostream>
#include <cmath>
using namespace std;
int main() {
float l, area;
cout << "Enter the value of length of a side: " << endl;
cin >> l;
area = pow(l,2);
cout << "Area of square: " << area;
return 0;
}
Output:
Enter the value of the length of a side: 3 Area of square: 9.00