//can some one please chech the wrong in this code i am new in c++ i feel that this may be easy question but it is hard for me
thanks
// Chapter 6, Programming Challenge 2
#include <iostream>
using namespace std;
// Write the prototypes for the getLength,
// getWidth, getArea, and displayData
// functions here.
double getLength(double);
double getWidth(double);
double getArea(double);
void displayData();
int main()
{
double length, // The rectangle's length
width, // The rectangle's width
area; // The rectangle's area
// Get the rectangle's length.
length = getLength(length);
// Get the rectangle's width.
width = getWidth(width );
// Get the rectangle's area.
area = getArea(length,width);
// Display the rectangle's data.
displayData(length, width, area);
system("pause");
return 0;
}
//***************************************************
// You must write the getLength, getWidth, getArea, *
// and displayData functions. *
//***************************************************
double getLength(double x)
{
cout<<"enter the length"<<endl;
cin>>x;
return x;
}
double getWidth(double x)
{
cout<<"enter the width"<<endl;
cin>>x;
return x;
}
double getArea(double x,double y)
{
double area=x*y;
return area;
}
void displayData(double x,double y,double z)
{
cout<<"the length is\t"<<x<<endl;
cout<<"the width is\t"<<y<<endl;
cout<<"the area is\t"<<z<<endl;
}
thanks
// Chapter 6, Programming Challenge 2
#include <iostream>
using namespace std;
// Write the prototypes for the getLength,
// getWidth, getArea, and displayData
// functions here.
double getLength(double);
double getWidth(double);
double getArea(double);
void displayData();
int main()
{
double length, // The rectangle's length
width, // The rectangle's width
area; // The rectangle's area
// Get the rectangle's length.
length = getLength(length);
// Get the rectangle's width.
width = getWidth(width );
// Get the rectangle's area.
area = getArea(length,width);
// Display the rectangle's data.
displayData(length, width, area);
system("pause");
return 0;
}
//***************************************************
// You must write the getLength, getWidth, getArea, *
// and displayData functions. *
//***************************************************
double getLength(double x)
{
cout<<"enter the length"<<endl;
cin>>x;
return x;
}
double getWidth(double x)
{
cout<<"enter the width"<<endl;
cin>>x;
return x;
}
double getArea(double x,double y)
{
double area=x*y;
return area;
}
void displayData(double x,double y,double z)
{
cout<<"the length is\t"<<x<<endl;
cout<<"the width is\t"<<y<<endl;
cout<<"the area is\t"<<z<<endl;
}
Last edited: