Area of parallelogram

Write a program to find the area of the parallelogram.

Formula: Area = base *height


Example 1:

Input: length=12,height=5
Output: 60


Approach: Given base and vertical height of the parallelogram.

Java

public class AreaofParallelogram {
    public static void main(String[] args) {
        double base = 12;
        double height = 5;
        double area = areaParallelogram(base, height);
        System.out.println("Area of parallelogram is " + area);
    }

    private static double areaParallelogram(double basedouble height) {
        return base * height;
    }
}

C++

#include <bits/stdc++.h>
using namespace std;
//function to find area of
//parallelogram
double areaParallelogram(double base,double height)
{
    double area=base*height;
    return area;
}
int main()
{
    double base=12;
    double height=5;
    double area=areaParallelogram(base,height);
    cout<<"Area of parallelogram is ";
    cout<<area<<"\n";
    return 0;
}


No comments:

Post a Comment