`1/2`

is an integer division which will yield zero. Possible working formulas:```
area = 0.5 * base * height;
area = (base * height) / 2;
area = (1.0 / 2) * base * height;
```

See more:

Write a program that calculates the area of a right triangle. The formula is one half the height multiplied by the base. You must assign values within the program (no user input). Dimensions are real numbers, so your variables should be type float. The result should be output to the screen in the following manner.

(Note: where you see ll(LL), hh, and aa below, there should be numbers)

The area of a right triangle with base length 11 and height hh is aa

**What I have tried:**

(Note: where you see ll(LL), hh, and aa below, there should be numbers)

The area of a right triangle with base length 11 and height hh is aa

#include <iostream> using namespace std; int main() { float base, height, area; base=10.3 height=13.56; area=1/2*base*height; cout<<”The area of a right triangle with base 10.3″<<base<<”and height 13.56″<<height<<”is”<<area<<endl; system(“pause”); return 0; }

Comments

please make is clear that you trying to display only two digits of float value?

Do you see no output or wrong output ?

dear, you have not shown us output.

I am not the author of question, and my comment is not for you.

The problem here is the same as in one of your former questions.

`1/2`

is an integer division which will yield zero. Possible working formulas:```
area = 0.5 * base * height;
area = (base * height) / 2;
area = (1.0 / 2) * base * height;
```

Comments

simply convert

`area=1/2*base*height;`

to `area=1/2.0*base*height;`

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8
+1 (416) 849-8900