Programa para hallar el area de un paralelogramo

Dados los lados de un paralelogramo, la tarea es calcular el área de un paralelogramo.
 

Ejemplos: 
 

Input: base = 30, height = 40
Output: 1200.000000
    As Area of parallelogram = base * height,
    Therefore, Area = 30 * 40 = 1200.00

Acercarse:
 

Area del paralelogramo = base * altura

A continuación se muestra la implementación del enfoque anterior:
 

C++

#include <iostream>
using namespace std;
 
// function to calculate the area
float CalArea(float base, float height)
{
    return (base * height);
}
// driver code
int main()
{
    float base, height, Area;
    base = 30;
    height = 40;
 
    // function calling
    Area = CalArea(base, height);
    // displaying the area
    cout << "Area of Parallelogram is :" << Area;
    return 0;
}

C

#include <stdio.h>
 
// function to calculate the area
float CalArea(float base, float height)
{
    return (base * height);
}
 
// driver code
int main()
{
    float base, height, Area;
    base = 30;
    height = 40;
 
    // function calling
    Area = CalArea(base, height);
 
    // displaying the area
    printf("Area of Parallelogram is : %f\n", Area);
    return 0;
}

Java

public class parallelogram {
    public static void main(String args[])
    {
        int base = 30;
        int height = 40;
 
        // formula for calculating the area
        int area_parallelogram = base * height;
 
        // displayin g the area
        System.out.println("Area of the parallelogram = " + area_parallelogram);
    }
}

Python

base = 30
height = 40 
 
# formula for finding the area
area_parallelogram = base * height
 
# displaying the output
print("Area of the parallelogram = "+str(area_parallelogram))

C#

using System;
class parallelogram
{
public static void Main()
{
    int b_ase = 30;
    int height = 40;
 
    // formula for calculating the area
    int area_parallelogram = b_ase * height;
 
    // displayin g the area
    Console.WriteLine("Area of the parallelogram = " +
                                  area_parallelogram);
}
}
 
// This code is contributed by vt_m

PHP

<?php   
   $base = 30; 
   $height = 40; 
   $area_parallelogram=$base*$height; 
    echo "Area of the parallelogram = "; 
    echo $area_parallelogram; 
?>

Javascript

<script>
 
let base = 30;
let height = 40;
let area_parallelogram=base*height;
document.write( "Area of the parallelogram = ");
document.write(area_parallelogram.toFixed(6));
     
// This code is contributed by Bobby
 
</script>
Producción: 

Area of Parallelogram is : 1200.000000

 

Complejidad de tiempo: O(1)

Espacio Auxiliar: O(1)

Publicación traducida automáticamente

Artículo escrito por Kanishk_Verma y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *