Write C++ program to find the area of a triangle?
Answers
Answered by
2
#include<iostream>
using namespace std;
void main( )
{
int base,height,area;
cout<<"Enter the base of traingle";
cin>>base;
cout<<"Enter the height of traingle";
cin>>height;
area=arOfTriangle(base,height);
cout<<"The area of triangle is "<<area;
}
public int arOfTriangle(int b,int h)
{
int ar=b*h*(1/2);
return ar;
}
using namespace std;
void main( )
{
int base,height,area;
cout<<"Enter the base of traingle";
cin>>base;
cout<<"Enter the height of traingle";
cin>>height;
area=arOfTriangle(base,height);
cout<<"The area of triangle is "<<area;
}
public int arOfTriangle(int b,int h)
{
int ar=b*h*(1/2);
return ar;
}
Shajithjoseph:
thankyou for this program.in my c++ compiler using namespace std wont work.. sorry it's my problem. i have not noticed that my compiler is turbo c++
Answered by
5
#include<iostream.h>
int main()
{
double a,b,h;
cout<<"Enter base of triangle:";
cin>>b;
cout<<"Enter height of triangle:";
cin>>h;
a=0.5 * b * h;
cout<<"Area of the triangle is:" <<a;
return 0;
}
int main()
{
double a,b,h;
cout<<"Enter base of triangle:";
cin>>b;
cout<<"Enter height of triangle:";
cin>>h;
a=0.5 * b * h;
cout<<"Area of the triangle is:" <<a;
return 0;
}
Similar questions