You are on page 1of 2

//******************************************************************************

//****GIVEN THE LENGTH AND WIDTH OF A RECTANGLE, THIS C++ PROGRAM **************
//****COMPUTES AND OUTPUTS THE PERIMETER AND AREA OF THE RECTANGLE ************
//******************************************************************************
#include <iostream>
using namespace std; ///*******this statement allows you to use the comman
ds: "cout" and "endl"
///*******whithout the prefix "std::" that means that
if you don't include this statement
///*******then "cout" should be used as std::cout and
"endl" should be used as std::endl.
///*******
//*******the << is an operator, called the stream in
sertion operator.
int main() //***this heading of the function main. in the next line the symbol "
{" (left brace) is the beginning of the function main
//***and the symbol "}"(rigth brace) means the finish of the function
main.
{
double length, width, area, perimeter; //*****DECLARATION OF VARIABLES*****//


cout<<"Program to compute and output the perimeter and" //****"cout"= is the
way to expose an output in the screen,
//in this case we sho
w us the string closed by double quotes (in spanish=comillas)
<<"area of a rectangle"<<endl;//*****"endl"=causes the insertition point
to be move to the beginning of the next line
///*********************cout = is for generate an ouput**********
///*********************endl = is the manipulator
//******AFTER THE DOUBLE LEFT ANGLE BRACKETS << AS FOLLEWED BY AND INSTRUCTION O
R DIRECTION OR CALL A FUNCTION OR VARIABLE OR AN IDENTIFIER.
//****A C++ PROGRAM IS A COLLECTION OF FUNCTIONS ONE OF WHICH IS THE FUNCTION ma
in. ROUGHLY SPEAKING, A FUNCTION IS A SET OF STATEMENTS
//****WHOSE OBJEECTIVE IS TO ACCOMPLISH SOMETHING. THE PRECEDING PROGRAM CONSIST
OF ONLY THE FUNCTION MAIN;
//**********************ALL C++ PROGRAMS REQUIRE A FUNCTION main**********

length=6.0; //ASSIGNMENT STATEMENT
width=4.0; //ASSIGNMENT STATEMENT
perimeter=2*(length+width); //ASSIGNMENT STATEMENT
area=length*width; //ASSIGNMENT STATEMENT

cout<<"Length = "<<length<<endl; //***OUTPUT OF THE STATEMENTS AND OTPUT
STATEMENT INSTRUCTS THE SYSTEM TO DISPLAY RESULTS***//
cout<<"Width = "<<width<<endl;//***OUTPUT OF THE STATEMENTS AND OTPUT STA
TEMENT INSTRUCTS THE SYSTEM TO DISPLAY RESULTS***//
cout<<"Perimeter = "<<perimeter<<endl;//***OUTPUT OF THE STATEMENTS AND O
TPUT STATEMENT INSTRUCTS THE SYSTEM TO DISPLAY RESULTS***//
cout<<"Area = "<<area<<endl;//***OUTPUT OF THE STATEMENTS AND OTPUT STATE
MENT INSTRUCTS THE SYSTEM TO DISPLAY RESULTS****//

system("PAUSE");
return 0;
}