Â
In this, we are going to see how to find Area of Triangle using C++ program.
The formula to calculate is,
Area of Triangle = 0.5 * length * breadthÂ
The Code given below can be used in Turbo C++ Compiler.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float area, base, height;
cout<<"This program is for Area of Triangle\n";
cout<<"Enter the Base and Height of the triangle\n";
cin>>base>>height;
//formula for area of triangle is 1/2 * base * height
area = 0.5*base*height;
cout<<"The Area of the Triangle with base "<<base<<" and height "<<height<<" is = "<<area<<" sq units";
getch();
}
#include<iostream>
using namespace std;
int main()
{
float area, base, height;
cout<<"This program is for Area of Triangle\n";
cout<<"Enter the Base and Height of the triangle\n";
cin>>base>>height;
//formula for area of triangle is 1/2 * base * height
area = 0.5*base*height;
cout<<"The Area of the Triangle with base "<<base<<" and height "<<height<<" is = "<<area<<" sq units";
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP