write a C++ program to find the area of a triangle
Answers
Answered by
7
Program to Calculate Area of Triangle in C++
#include <iostream>
using namespace std;
int main() {
int height, base;
float ans; //ans may come in fractions.
cout<<"Enter height and base : ";
cin>>height>>base;
ans= (0.5)*height*base; //area of triangle formula
#include <iostream>
using namespace std;
int main() {
int height, base;
float ans; //ans may come in fractions.
cout<<"Enter height and base : ";
cin>>height>>base;
ans= (0.5)*height*base; //area of triangle formula
divergent07:
i think iostream.h
Answered by
8
Answer:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float base, height,area;
cout<<"\nEnter base";
cin>>base;
cout<<"\nEnter height";
cin>>height;
area=0.5*base*height;
cout<<"\nArea of triangle="<<area;
getch();
}
Explanation:
Since, area of triangle is (ab) /2, 1/2 is considered as 0.5 and a, b is considered as base and height respectively.
Similar questions
Hindi,
7 months ago
Biology,
7 months ago
Math,
1 year ago
Social Sciences,
1 year ago
Social Sciences,
1 year ago
Science,
1 year ago