181k views
2 votes
Develop a program that will calculate the area and perimeter of a rectangle. The length and width can be given as constant.(LENGTH= 8 WIDTH=8).

User Jb Drucker
by
7.6k points

1 Answer

5 votes

Answer:

#include <iostream>

using namespace std;

int main()

{

int length = 8;

int width = 8;

int perimeter = 2*(length + width);

int area = length * width;

cout<<"The perimeter is "<<perimeter<<endl;

cout<<"The area is "<<area<<endl;

return 0;

}

Step-by-step explanation:

include the library iostream for using the input/output instructions in the c++ programming.

Create the main function and define the variable length and width with values.

Then, use the formula for calculating the perimeter and area of rectangle.


perimeter = 2*(length + width)


area = length * width

and store in the variables and finally print the output.

User Glenn Werner
by
8.3k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.