Calculate the perimeter in c++

April 26, 2013

Calculate the perimeter in c++


Write a C++ program that stores the integer value 16 in the variable length and the integer value 18 in the variable width of a rectangle. Have your program calculate the perimeter of the shape and store the value in the variable perimeter. Use the cout object to display the perimeter.


Algorithm

STEP#1    Start
STEP#2    Declare the variable Length, Width, Perimeter
STEP#3    Assign value 16 to Length
STEP#4    Assign value 18 to Width
STEP#5    Calculate value of Perimeter
STEP#6    Perimeter= 2(Length+Width)
STEP#7    Display the Perimeter
STEP#8    End




Code


#include <iostream>
using namespace std;
int main()
{
    int Lenth,Weidth,Perimeter;
    Lenth=16;
    Weidth=18;
    Perimeter=2*(Lenth+Weidth);
    cout<<"your answer is "<<Perimeter;
    return 0;
}


C++ program that stores the integer value 16




You Might Also Like

0 comments

Popular Posts

Like us on Facebook

Flickr Images