C++ program that computes for the area of a rectangle. There are two set of measurements give below
Rectangle 1 has a length of 8 and a width of 5.
Rectangle 2 has a length of 4 and a width of 20.
Answers
Answered by
5
#include <iostream>
using namespace std;
int main() {
int s1m1 = 8;
int s1m2 = 5;
int s2m1 = 4;
int s2m2 = 20;
cout << s1m1 * s1m2 << " is the area of rectangle 1" << endl;
cout << s2m1 * s2m2 << " is the area of rectangle 2";
return 0;
}
- First of all we included a header file.
- Then we listed the standard namespace.
- C++ ignores white spaces.
- int main is the main method required to run almost every valid program.
- We declared 4 variables with their values respectively.
- Then we printed them using the formulas.
- endl is used for a new line.
- 'return 0;' ends the main method.
Hope it helps...
Similar questions