Knowledge Is Better

Area Computation of a Trapezoid in C++

Trapezoid is a quadrilateral with two parallel sides. The Area of a trapezoid is equal to the average length of the two parallel side multiply by the height.


In this example you will learn how to create an application from a given formula and write a simple program that will accept input or data from the user.


Recommended to Read First: Defining Variables and Input Output Operations in C++


The same with the first and second example, create an empty project first, add a cpp file and use any name that you want.



If your a first time user of Visual C++ Express Edition, it is recommended to read the step by step procedure. Read here



#include <iostream>
using namespace std;

int main()
    int parallelsidea;
    int parallelsideb;
    int height;
    int Area;

    cout << "Enter the length of the first parallel side: ";
    cin >> parallelsidea;

    cout << endl << "Enter the length of the second parallel side: ";
    cin >> parallelsideb;

    cout << endl << "Enter the height: ";
    cin >> height;

    Area = (parallelsidea + parallelsideb) / 2 * height;

    cout << endl << "Area of the Trapezoid: " << Area << endl;       

    return 0;


Press F5 to run the program.





© Knowledge Is Better 2010 | Blogger|| License Agreement