output is Zero

What is the wrong in this code it alwasys gives me zero

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  #include <iostream>

using namespace std;

class Triangle
{
public:int area(int height,int length)
        {
        return 1/2*height*length;
        }
};


int main()
{
    int num1,num2;
    cout<<"Enter two number"<<endl;
    cin>>num1,num2;
    Triangle t;
    cout<<t.area(num1,num2)<<endl;
    return 0;
}
Line 9: You're doing integer arithmetic. 1/2=0. 0 times anything is still 0.

Topic archived. No new replies allowed.