# Thread: homework question - Standard Libraries

1. ## homework question - Standard Libraries

Hello guys! As you can tell its about standard libraries. I need to turn it in soon, but can not get a hold of the teacher.

This is the code it's based on.

Code:
```#include <iostream>
using namespace std;
#include "C:\\Dev-Cpp\\user_area\\udst_monitor.h"

// Function Prototypes

double area_square(double side);
double area_rectangle(double side1, double side2);
double area_trapezoid(double base, double top, double height);

// Variables

double  square_room_size;
double  driveway_length;
double  driveway_width;
double  swimming_pool_diameter;
double  trap_bottom;
double  trap_top;
double  trap_height;

//******************************************************
// main
//******************************************************

int main(void)
{
// *************************** square
// Input Test Data - 4.5
cout << "\nWhat is the length of one of the walls in your square bedroom? -->: ";
cin >> square_room_size;
// Output Test Results - 20.25
cout << "\nYour room is " << area_square(square_room_size) << " square whatevers.\n";
pause_m();
clear_m();

// *************************** rectangle
// Input Test Data - 4.5
cout << "\nWhat is the length of your driveway? -->: ";
cin >> driveway_length;
// Input Test Data - 6.6
cout << "\nWhat is the width of your driveway? --->: ";
cin >> driveway_width;
// Output Test Results - 29.7

cout << "\nYour driveway is " << area_rectangle(driveway_length, driveway_width) << " square whatevers.\n";
pause_m();
clear_m();

// *************************** circle
// Input Test Data - 13.8
cout << "\nWhat is the diameter of your circular swimming_pool? -->: ";
cin >> swimming_pool_diameter;
// Output Test Results - 149.571
cout << "\nYour pool is " << area_circle(swimming_pool_diameter / 2) << " square whatevers.\n";
pause_m();
clear_m();

// *************************** trapezoid
// Input Test Data - 12.7
cout << "\nWhat is the length of the bottom side of your trapezoid? -->: ";
cin >> trap_bottom;
// Input Test Data - 9.3
cout << "\nWhat is the length of the top side of your trapezoid? ----->: ";
cin >> trap_top;
// Input Test Data - 4.2
cout << "\nHow tall is your trapezoid? ------------------------------->: ";
cin >> trap_height;
// Output Test Results - 46.2
cout << "\nYour trapezoid is " << area_trapezoid(trap_bottom, trap_top, trap_height) << " square whatevers.\n";
pause_m();
clear_m();

return 0;
}

//******************************************************
// area_square
//******************************************************

double area_square(double side)
{
return side * side;
}

//******************************************************
// area_rectangle
//******************************************************

double area_rectangle(double side1, double side2)
{
return side1 * side2;
}

//******************************************************
// area_circle
//******************************************************

{
}

//******************************************************
// area_trapezoid
//******************************************************

double area_trapezoid(double base, double top, double height)
{
return (base + top) / 2 * height;
}```
We need to creat a function called "area_triangle" , prototype it and within the function main we need to add an area for calling the function.

But I have no idea what he means by "area_triangle"? Does anybody know what that is supposed to do?

2. The normal way to calculate the area of a triangle would be to take 1/2(Base * Height).

3. Thanks. So in this case 0.5(area_square * Height) ? ops no, its base. Nevermind then.

4. BTW, you should never put a using statement before any #include statements, otherwise you might change the meaning of some of the code in the header file.

5. Originally Posted by rt454
The normal way to calculate the area of a triangle would be to take 1/2(Base * Height).
I find it more obvious to say it's

Base * Height / 2
Or just
Base * Height * 0.5

6. > #include "C:\\Dev-Cpp\\user_area\\udst_monitor.h"
This should be
#include "udst_monitor.h"

Then in the compiler project settings, you add the path to the pre-processor search directories.
Something like
-IC:\Dev-Cpp\user_area

> // Variables
> double square_room_size;
All these variables should be local to main