Write a program to find the Area of a trapezoid?
Area of a trapezoid =(1/2)* (a+b)* h;
h = vertical height
Source Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <iostream.h> #include <conio.h> int main() { float A, a, b, h; cout << "Area of a trapezoid Formula: A =(1/2)* (a+b)* h\n"; cout << "\tEnter the value of a?\n"; cin >> a ; cout << "\tEnter the value of b?\n"; cin >> b ; cout << "\tEnter the value of h?\n"; cin >> h; a = a + b; h = h * a; A = h * 0.5; cout << " \tArea of a trapezoid = " << A << " m^2 " << endl; getch(); return 0; } // end main |
Output:
Area of a trapezoid Formula: A =(1/2)* (a+b)* h Enter the value of a? 46 Enter the value of b? 52 Enter the value of h? 3 Area of a trapezoid = 147 m^2
No comments:
Post a Comment