Definición de trapezoide:
un trapezoide es un cuadrilátero convexo con al menos un par de lados paralelos. Los lados paralelos se llaman bases del trapezoide y los otros dos lados que no son paralelos se llaman catetos. También puede haber dos pares de bases.
En la figura anterior CD || AB, por lo que forman las bases y los otros dos lados, es decir, AD y BC forman las piernas.
El área de un trapezoide se puede encontrar usando esta fórmula simple:
a = base
b = base
h = altura
Ejemplos:
Input : base1 = 8, base2 = 10, height = 6 Output : Area is: 54.0 Input :base1 = 4, base2 = 20, height = 7 Output :Area is: 84.0
C++
// C++ program to calculate // area of a trapezoid #include<bits/stdc++.h> using namespace std; // Function for the area double Area(int b1, int b2, int h) { return ((b1 + b2) / 2) * h; } // Driver Code int main() { int base1 = 8, base2 = 10, height = 6; double area = Area(base1, base2, height); cout << "Area is: " << area; return 0; } // This code is contributed by shivanisinghss2110
C
// CPP program to calculate // area of a trapezoid #include <stdio.h> // Function for the area double Area(int b1, int b2, int h) { return ((b1 + b2) / 2) * h; } // Driver Code int main() { int base1 = 8, base2 = 10, height = 6; double area = Area(base1, base2, height); printf("Area is: %.1lf", area); return 0; }
Java
// Java program to calculate // area of a trapezoid import java.io.*; class GFG { // Function for the area static double Area(int b1, int b2, int h) { return ((b1 + b2) / 2) * h; } // Driver Code public static void main (String[] args) { int base1 = 8, base2 = 10, height = 6; double area = Area(base1, base2, height); System.out.println("Area is: " + area); } }
Python3
# Python program to calculate # area of a trapezoid # Function for the area def Area(b1, b2, h): return ((b1 + b2) / 2) * h # Driver Code base1 = 8; base2 = 10; height = 6 area = Area(base1, base2, height) print("Area is:", area)
C#
// C# program to calculate // area of a trapezoid using System; class GFG { // Function for the area static double Area(int b1, int b2, int h) { return ((b1 + b2) / 2) * h; } // Driver Code public static void Main () { int base1 = 8, base2 = 10, height = 6; double area = Area(base1, base2, height); Console.WriteLine("Area is: " + area); } } // This code is contributed by vt_m
PHP
<?php // PHP program to calculate // area of a trapezoid // Function for the area function Area( $b1, $b2, $h) { return (($b1 + $b2) / 2) * $h; } // Driver Code $base1 = 8; $base2 = 10; $height = 6; $area = Area($base1, $base2, $height); echo("Area is: "); echo($area); // This code is contributed by vt_m. ?>
Javascript
<script> // Javascript program to calculate // area of a trapezoid // Function for the area function Area(b1, b2, h) { return ((b1 + b2) / 2) * h; } // Driver Code let base1 = 8, base2 = 10, height = 6; let area = Area(base1, base2, height); document.write("Area is: " + area); // This code is contributed by Mayank Tyagi </script>
Producción :
Area is: 54.0
Complejidad del tiempo: O(1)
complejidad del espacio: O(1)
Publicación traducida automáticamente
Artículo escrito por Chinmoy Lenka y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA