Output for Area isn't correct or calculating?

I'm doing a simple sample exercise program for C++ that is asking me to have the user input a Base and a Height and calculate the two in order to find the Area.

The given formula for Area is: Area = 1/2 * Base * Height

After the user inputs the Base and Height, it should calculate and then output the Area. For some reason, no matter what numbers I enter, it keeps outputting Area as Zero. Can someone take a look at this and see if I'm doing something incorrect?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;
// START PROTOTYPE

void InputBaseHeight(double Base, double Height);
double TriangleArea(double Base, double Height, double Area);
void PrintArea(double Area);

// END PROTOTYPE

// START MAIN
int main()
{
    double Base = 0.0, Height = 0.0, Area = 0.0;

    // Call InputBaseHeight

    InputBaseHeight(Base, Height);

    // Call TriangleArea

    TriangleArea(Base, Height, Area);

    // Call PrintArea

    PrintArea(Area);

    return 0;
}
// END MAIN

// START FUNCTION DEFINITIONS
void InputBaseHeight(double Base, double Height)
{
    cout << "Enter the Base: ";
    cin >> Base;

    cout << "Enter the Height: ";
    cin >> Height;

}

double TriangleArea(double Base, double Height, double Area)
{
    double TriArea = 0.0;

    TriArea = (1/2) * Base * Height;
    Area =  TriArea;

    return Area;
}

void PrintArea(double Area)
{
    cout << "The Area of the Triangle is: " << Area;
}
TriArea = (1/2) * Base * Height;
Should be :
TriArea = (1.0 / 2.0) * Base * Height;
Still coming back as 0, could it be that my input isn't being used somehow?
Topic archived. No new replies allowed.