A Program to Find the Area of a Rectangle
In this example, we are giving a program to find the area of a rectangle. The rule of finding the area of a rectangle is: A = width * height.
Program to find the area of a rectangle:
#include <iostream>#include <cmath>using namespace std;int main() {float w, h, area;cout << "Enter the value of width and height: " << endl;cin >> w >> h;area = w * h;cout << "Area of rectangle: " << area;return 0;}
Output:
Enter the value of width and height: 3, 4 Area of rectangle: 12.00