Calculate area of a Triangle in C++ - 👑 सार्थक मुंड S3 🤴🏻

Calculate area of a Triangle in C++

banner

Write a program (WAP) in C++ to read two numbers from keyboard(User Input) and calculate the area of a Triangle.

#include <iostream>
using namespace std;
int main()
{
    float b, h, area;

    cout<<"Enter Base of the triangle (b):\n";
    cin>> b;
    cout<<"Enter Height of the triangle (h):\n";
    cin>> h;

    area = (b * h) / 2;

    cout<<"Area of the triangle is ="<<area<< "sq. units\n";

    return 0;
}

Try it Yourself ➠
out put

 

Note :-

1. You can also write "area=.5*b*h"

Must Read :-
  1. Blogger Tutorial
  2. C Programs
  3. C++ Programs
  4. Java Programs
  5. Python Programs
  6. Programming Notes 
  7. Questions & Answers
  8. My Codes : HTML, CSS & JS
  9. All Subject Notes

Previous article
Next article

Leave Comments

Post a Comment

Articles Ads

Articles Ads 1

Articles Ads 2

Advertisement Ads