Computer Science, asked by anann, 1 year ago

write a C++ program to find the area of a triangle

Answers

Answered by shiv7020
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


divergent07: i think iostream.h
divergent07: incomplete hai
Answered by Soñador
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