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

Input: base = 10, height = 8
Output: 40
Explanation:
Using the formula: Area = (base * height) / 2
= (10 * 8) / 2
= 80 / 2 = 40
=> Area = 40

Scenario 2

Input: base = 15, height = 12
Output: 90
Explanation:
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
Updated on: 2025-07-28T14:07:59+05:30

558 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements