I am trying to create a program in C++ to calculate the area of a triangle using functions. I keep getting back 0 as my answer for the area, not sure what I'm doing wrong. I've included my code below. I'm new to using functions any help or suggestions would be greatly appreciated.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
// complete the following three functions
// The function InputBaseHeight will read the values for the Base and Height of a Triangle from the keyboard
// and pass the Base and Height values back through a reference parameter.
void InputBaseHeight(double height, double Base)
{
cout << "\n Enter height = "; cin >> height;
cout << "\n Enter Base = "; cin >> Base;
}
// The function TriangleArea will receive the Base and Height values through a value parameter and
// return the Area of the Triangle through the function name
double TriangleArea(double height, double Base, double Area)
{
// Area = 1/2 * Base * Height
return Area = Base/2 * height;
}
// The function PrintArea will receive the Area value through a value parameter
// and label and print the Area value.
void PrintArea(double height, double Base, double Area)
{
cout << "\n The area of the triangle = " << Area;
}
int main()
{
double Base = 0.0, height = 0.0, Area = 0.0;
// call InputBaseHeight function
InputBaseHeight(height, Base);
// call TriangleArea function
TriangleArea(height, Base, Area);
// call PrintArea
PrintArea(height, Base, Area);
cout<< "\n\n The End";
return 0;
}