Dados los lados del paralelogramo, calcula la circunferencia.
Ejemplos:
Input: a = 10, b = 8 Output: 36.00 Input: a = 25.12, b = 20.4 Output: 91.04
Los lados opuestos de un paralelogramo son de igual longitud y paralelos. Los ángulos son iguales por pares pero no necesariamente de 90 grados. La circunferencia de un paralelogramo se puede calcular como la suma de dos lados adyacentes, cada uno multiplicado por 2.
Fórmula utilizada para calcular la circunferencia de un paralelogramo:
(2*a)+(2*b)
C++
// C Program to calculate the // Circumference of a Parallelogram. #include <stdio.h> float circumferenceparallelogram(float a, float b) { return ((2 * a) + (2 * b)); } int main() { float a = 10, b = 8; printf("Circumference of a given Parallelogram is : %.2f", circumferenceparallelogram(a, b)); return 0; }
Java
// Java Program To Calculate // Circumference of a Parallelogram import java.io.*; class GFG { static float circumferenceparallelogram(float a, float b) { return ((2 * a) + (2 * b)); } // Driver code public static void main(String arg[]) { float a = 10, b = 8; System.out.print("Circumference of a given Parallelogram is :"); System.out.println(circumferenceparallelogram(a, b)); } } // This code is contributed by Anant Agarwal.
Python3
# Python3 Program to calculate the # Circumference of a Parallelogram # Utility Function def circumferenceparallelogram(a,b): return ((2 * a) + (2 * b)) # Driver Function a = 10 b = 8 print("Circumference of a given Parallelogram is :", round(circumferenceparallelogram(a, b),4)) # This code is contributed # by Azkia Anam.
C#
// C# Program To Calculate // Circumference of a Parallelogram using System; class GFG { static float circumferenceparallelogram(float a, float b) { return ((2 * a) + (2 * b)); } // Driver code public static void Main() { float a = 10, b = 8; Console.Write("Circumference of a" + "given Parallelogram is :"); Console.Write(circumferenceparallelogram(a, b)); } } // This code is contributed by vt_m.
PHP
<?php // PHP Program to calculate // the Circumference of a // Parallelogram. function circumferenceparallelogram( $a, $b) { return ((2 * $a) + (2 * $b)); } $a = 10; $b = 8; echo "Circumference of a ". "given Parallelogram is : ", circumferenceparallelogram($a, $b); // This code is contributed by anuuj_67. ?>
Javascript
<script> // Javascript Program to calculate the // Circumference of a Parallelogram. function circumferenceparallelogram(a, b) { return ((2 * a) + (2 * b)); } // Driver code let a = 10, b = 8; document.write("Circumference of a given Parallelogram is : ", circumferenceparallelogram(a, b)); // This code is contributed by Manoj </script>
Producción :
Circumference of a given parallelogram is : 36.0
Complejidad de tiempo: O(1)
Espacio Auxiliar: O(1)
Publicación traducida automáticamente
Artículo escrito por azkia anam y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA