CPP
#include <iostream>
Try it Yourself ➠
Calculate area of a Triangle in C++
13 May
0
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 ➠
Note :-
1. You can also write "area=.5*b*h"
Must Read :-
- Blogger Tutorial
- C Programs
- C++ Programs
- Java Programs
- Python Programs
- Programming Notes
- Questions & Answers
- My Codes : HTML, CSS & JS
- All Subject Notes
Previous article
Next article
Leave Comments
Post a Comment