Related Articles

Related Articles

Program to find the Area of a Parallelogram
  • Last Updated : 01 Nov, 2018

Given the sides of a Parallelogram, task is calculate the area of a Parallelogram.

Examples:

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

Approach:

Area of parallelogram = base * height



Below is the implementation of the above approach:

C++

filter_none

edit
close

play_arrow

link
brightness_4
code

#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;
}

chevron_right


C

filter_none

edit
close

play_arrow

link
brightness_4
code

#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;
}

chevron_right


Java

filter_none

edit
close

play_arrow

link
brightness_4
code

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);
    }
}

chevron_right


Python

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


C#

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


PHP

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

Area of Parallelogram is : 1200.000000

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.




My Personal Notes arrow_drop_up
Recommended Articles
Page :