Monday, October 24, 2022

C++ Problem (6) : How to find the area of triangle while base and hight of the triangle are given?

 C++: (6) : How to find the area of a triangle while base and hight of the triangle are given?

Code:

#include<iostream>
using namespace std;
int main(){
double b,h,a;
cout<<"*****Finding the area of a Triangle.*****"<<endl;
cout<<"Enter the base."<<endl;
cin>>b;

cout<<"Enter the height."<<endl;
cin>>h;

       a= (b*h)/2;

cout<<"The area of triangle having base "<<b<<" and height "<<h<<" is: "<<a<<endl;
return 0;
}

OutPut:

*****Finding the area of a Triangle.*****
Enter the base.
5
Enter the height.
10
The area of triangle having base 5 and height 10 is: 25

No comments:

Post a Comment

 How to create a shortcut for a program(application) on windows? Fisrt of all if you are at desktop screen, click right on mouse and click o...