Problem statement:- Program to compute the area of the Trapezoid.
Formula:
Area Of Trapezoid(A):
Formula:
Area Of Trapezoid(A):
where a and b=base length of the Trapezoid
h= height of the Trapezoid
h= height of the Trapezoid
Data requirement:-
Input Data:- a, b, h
Output Data:- area
Output Data:- area
Program in C
Here is the source code of the C Program to compute the area of the Trapezoid.
Code:
#include<stdio.h>
#include<math.h>
int main()
{
printf("Enter the value of base:");
int a,b;
scanf("%d%d",&a,&b);
int h;
printf("Enter the value of height:");
scanf("%d",&h);
double area=((a+b)*h)/2.0;
printf("Area of the Trapezoid = %0.2lf\n",area);
}
#include<math.h>
int main()
{
printf("Enter the value of base:");
int a,b;
scanf("%d%d",&a,&b);
int h;
printf("Enter the value of height:");
scanf("%d",&h);
double area=((a+b)*h)/2.0;
printf("Area of the Trapezoid = %0.2lf\n",area);
}
Input/Output:
Enter the value of base:5
7
Enter the value of height:8
Area of the Trapezoid = 48.00
Program in C++
Here is the source code of the C++ Program to compute the area of the Trapezoid.
7
Enter the value of height:8
Area of the Trapezoid = 48.00
Program in C++
Here is the source code of the C++ Program to compute the area of the Trapezoid.
Code:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
cout<<"Enter the value of base:";
int a,b;
cin>>a;
cin>>b;
int h;
cout<<"Enter the value of height:";
cin>>h;
double area=((a+b)*h)/2.0;
cout<<"Area of the Trapezoid = "<<area;
}
Input/Output:#include<cmath>
using namespace std;
int main()
{
cout<<"Enter the value of base:";
int a,b;
cin>>a;
cin>>b;
int h;
cout<<"Enter the value of height:";
cin>>h;
double area=((a+b)*h)/2.0;
cout<<"Area of the Trapezoid = "<<area;
}
Enter the value of base:4
9
Enter the value of height:10
Area of the Trapezoid = 65
Program in Java
9
Enter the value of height:10
Area of the Trapezoid = 65
Program in Java
Here is the source code of the Java Program to compute the area of the Trapezoid.
Code:
import java.util.Scanner;
public class Area_Trapezoid {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
System.out.println("Enter the value of base:");
int a=cs.nextInt();
int b=cs.nextInt();
int h;
System.out.println("Enter the value of height:");
h=cs.nextInt();
double area=((a+b)*h)/2.0;
System.out.println("Area of the Trapezoid = "+area);
cs.close();
}
}
public class Area_Trapezoid {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
System.out.println("Enter the value of base:");
int a=cs.nextInt();
int b=cs.nextInt();
int h;
System.out.println("Enter the value of height:");
h=cs.nextInt();
double area=((a+b)*h)/2.0;
System.out.println("Area of the Trapezoid = "+area);
cs.close();
}
}
Input/Output:
Enter the value of base:
11
13
Enter the value of height:
24
Area of the Trapezoid = 288.0
11
13
Enter the value of height:
24
Area of the Trapezoid = 288.0
Program in Python
Here is the source code of the Python Program to compute the area of the Trapezoid.
Code:
print("Enter the value of base:")
a=int(input())
b=int(input())
h=int(input("Enter the value of height:"))
area=((a+b)*h)/2.0
print("Area of the Trapezoid = ",area)
Enter the value of base:
6
10
Enter the value of height:12
Area of the Trapezoid = 96.0
6
10
Enter the value of height:12
Area of the Trapezoid = 96.0
Most Recommend Questions:-
More Questions:-
0 Comments
Please do not Enter any spam link in the comment box