Un rectángulo es una figura plana en un plano. Tiene cuatro lados y cuatro ángulos iguales de 90 grados cada uno. En el rectángulo, los cuatro lados no tienen la misma longitud que en el cuadrado, los lados opuestos entre sí tienen la misma longitud. Ambas diagonales del rectángulo tienen la misma longitud.
C++
// CPP program to find area // and perimeter of rectangle #include<bits/stdc++.h> using namespace std; // Utility function int areaRectangle(int a, int b) { int area = a * b; return area; } int perimeterRectangle(int a, int b) { int perimeter = 2*(a + b); return perimeter; } // Driver program int main() { int a = 5; int b = 6; cout << "Area = " << areaRectangle(a, b) << endl; cout << "Perimeter = " << perimeterRectangle(a, b); return 0; }
Java
// Java program to find area // and perimeter of rectangle import java.io.*; class Geometry { // Utility function static int areaRectangle(int a, int b) { int area = a * b; return area; } static int perimeterRectangle(int a, int b) { int perimeter = 2*(a + b); return perimeter; } // Driver Function public static void main (String[] args) { int a = 5; int b = 6; System.out.println("Area = "+ areaRectangle(a, b)); System.out.println("Perimeter = "+ perimeterRectangle(a, b)); } } // This code is contributed by Chinmoy Lenka
Python3
# Python3 code to find area # and perimeter of rectangle # Utility function def areaRectangle(a, b): return (a * b) def perimeterRectangle(a, b): return (2 * (a + b)) # Driver function a = 5; b = 6; print ("Area = ", areaRectangle(a, b)) print ("Perimeter = ", perimeterRectangle(a, b)) # This code is contributed by 'saloni1297'.
C#
// C# program to find area // and perimeter of rectangle using System; class GFG { // Utility function static int areaRectangle(int a, int b) { int area = a * b; return area; } static int perimeterRectangle(int a, int b) { int perimeter = 2 * (a + b); return perimeter; } // Driver Function public static void Main() { int a = 5; int b = 6; Console.WriteLine("Area = " + areaRectangle(a, b)); Console.WriteLine("Perimeter = " + perimeterRectangle(a, b)); } } // This code is contributed by vt_m.
PHP
<?php // PHP program to find area // and perimeter of rectangle // Utility function function areaRectangle( $a, $b) { $area = $a * $b; return $area; } function perimeterRectangle( $a, $b) { $perimeter = 2 * ($a + $b); return $perimeter; } // Driver program $a = 5; $b = 6; echo("Area = " ); echo(areaRectangle($a, $b)); echo("\n"); echo( "Perimeter = "); echo(perimeterRectangle($a, $b)); // This code is contributed by vt_m. ?>
Javascript
<script> // Javascript program to find area // and perimeter of rectangle // Utility function function areaRectangle(a, b) { let area = a * b; return area; } function perimeterRectangle(a, b) { let perimeter = 2*(a + b); return perimeter; } // Driver program let a = 5; let b = 6; document.write("Area = " + areaRectangle(a, b) + "<br>"); document.write("Perimeter = " + perimeterRectangle(a, b)); // This code is contributed by Manoj </script>
Publicación traducida automáticamente
Artículo escrito por GeeksforGeeks-1 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA