Write a C++ program that inputs base and height from the user. It calculates and displays the area of a triangle by using formula Area = 1/2 * Base * Height.


#include<iostream>

using namespace std;

int main()

{

float base, height;

double area;

cout<<"Enter base: ";

cin>>base;

cout<<"Enter height: ";

cin>>height;

area = 0.5 * base * height;

cout<<"Area = "<<area;

OUTPUT

Enter base: 10.5

Enter height: 5.4

Area = 28.35

No comments:

Post a Comment