Write a program that stores the value 16 in the variable length and the value 18 in the variable width. Have your program calculate the value assigned to the variable perimeter using the formula perimeter = 2 * length + 2 * width. Have your program print the value stored in perimeter.

Respuesta :

Answer:

#include<iostream>

using namespace std;

int main()

{

  int length = 16;

   int width = 18;

   int perimeter = (2*length) + (2 * width);

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

}

Explanation:

First include the library iostream in the c++ program for input/output.

then, create the main function and define the variable with given values in the length and width.

After that calculate the perimeter by using the formula.

perimeter = 2*length + 2*width

and finally display the output  on the screen by using the cout instruction.