Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Area of a triangle inside a parallelogram in C++
The area of a triangle is given as (base * height) / 2, and the area of a parallelogram is base * height. For calculating the area of the triangle inside the parallelogram, we divide the area of the parallelogram by 2, i.e., (base * height) / 2, where the base and the height of the parallelogram are given.

Here are some example scenarios to calculate the area of a triangle inside a parallelogram using the above formula:
Scenario 1
<strong>Input:</strong> base = 10, height = 8 <strong>Output:</strong> 40 <strong>Explanation:</strong> Using the formula: Area = (base * height) / 2 = (10 * 8) / 2 = 80 / 2 = 40 => Area = 40
Scenario 2
<strong>Input:</strong> base = 15, height = 12 <strong>Output:</strong> 90 <strong>Explanation:</strong> Using the formula: Area = (base * height) / 2 = (15 * 12) / 2 = 180 / 2 = 90 => Area = 90
Program to Find Area of Triangle Inside Parallelogram
In this example, we have used the formula (Area = (base * height) / 2) to find the area of the triangle inside a parallelogram:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double base = 10, height = 8;
double area = (base * height) / 2.0;
cout << "Base of Parallelogram: " << base << endl
<< "Height of Parallelogram: " << height << endl;
cout << "Area of Triangle: " << area;
return 0;
}
The output of the above code is as follows:
Base of Parallelogram: 10 Height of Parallelogram: 8 Area of Triangle: 40
Advertisements
