0% found this document useful (0 votes)
30 views2 pages

Rectangle Are A

Calculating rectangle area

Uploaded by

Kelvin Muriuki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Rectangle Are A

Calculating rectangle area

Uploaded by

Kelvin Muriuki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//program to calculate area of a rectangle

#include <iostream>
using namespace std;

double getLength();
double getWidth();
void displayData(double, double, double);
double getArea(double, double);

//parameters
//argument counter
//argument vector
int main(int argc, char *argv[])
{
double length;
double width;
double area;

length = getLength();
width = getWidth();
area = getArea(length, width);
displayData(length, width, area);

return 0;
}
// function to get Length
double getLength()
{
double rectLength;

cout<<"Enter the length of the rectangle: ";


cin>>rectLength;
//returns value
return rectLength;

//function to get Width


double getWidth()
{
double rectWidth;

cout<<"Enter the width of the rectangle: ";


cin>>rectWidth;
//returns value
return rectWidth;
}

void displayData(double length = 20, double width = 40, double area = 800)
{

cout<<"Rectangle's Area: "<<area<<endl;


}
double getArea(double length = 10, double width = 20)
{
return length * width;
}

You might also like