The Code given below can be used in Turbo C++ Compiler.
Â
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
float b1, b2, h, area;
cout << "Enter Upper base length of trapezoid : ";
cin >> b1;
cout << "\n Enter Lower base length of trapezoid : ";
cin >> b2;
cout << "\n Enter Height of trapezoid : ";
cin >> h;
/*formula for area of trapezoid is (1/2)*(upper base length+lower base length)*height.*/
area = (b1 + b2) * h / 2;
cout << "\n Area of Trapezoid is : " << area<<" sq units";
getch();
}
//..........Coded by RISHAB NAIR
The Code given below can be used in g++/gcc Compiler.
#include <iostream>
using namespace std;
int main()
{
float b1, b2, h, area;
cout << "Enter Upper base length of trapezoid : ";
cin >> b1;
cout << "\n Enter Lower base length of trapezoid : ";
cin >> b2;
cout << "\n Enter Height of trapezoid : ";
cin >> h;
/*formula for area of trapezoid is (1/2)*(upper base length+lower base length)*height.*/
area = (b1 + b2) * h / 2;
cout << "\n Area of Trapezoid is : " << area<<" sq units";
}
//..........Coded by RISHAB NAIR
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP