### Easyway How To Write a Program in C++ for Calculating Area of Triangle When base and height is given

Program Statement: Write a C++ program to input base and height of a triangle and calculates and prints the area and triangle.Input base and height, compute area of triangle c++ program |

### What are the Formulas for Area of Triangle when base and height are given

These are as follows:

- area of triangle = 1 / 2 x base x height

#### How Formula of Area of Triangle is Transformed into C++ Arithmetic Expressions

In C++ programming, we write the above formula as follows#### area = 1.0/2.0 * base * height

### C++ Source Code for Calculating Area of Triangle When Base and Height are Given

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

void main()

{

float area, base, height;

clrscr();

cout<<"Enter base = ";

cin>>base;

cout<<"Enter height = ";

cin>>height;

area = 1.0 / 2.0 * base * height;

cout<<"Area of Triangle = "<<setprecision(2)<<area<<endl;

getch();

}

### Sample Run Output Window: Area of Triangle in C Plus Plus Program

### How This Program works : C++ Source Code for Calculating Area of Triangle When Base and Height are Given

#include<iostream.h> //include for cin, cout

#include<conio.h> //include for clrscr()

#include<iomanip.h> //include for setprecision()

void main()

{

float area, base, height; //declare variables

clrscr();

cout<<"Enter base = ";

cin>>base; //input base

cout<<"Enter height = ";

cin>>height; //input height

area = 1.0 / 2.0 * base * height; //compute area

cout<<"Area of Triangle = "<<setprecision(2)<<area<<endl; // show result

getch();

}