Problem statement:- Program to compute the perimeter of the Trapezoid.
Formula:
Perimeter of Pentagon(P):
Formula:
Perimeter of Pentagon(P):
P=
a+b+c+d
Data requirement:-
Input Data:- a, b, c, d
Output Data:- perimeter
Output Data:- perimeter
Program in C
Here is the source code of the C Program to compute the perimeter 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 c,d;
printf("Enter the value of side:");
scanf("%d%d",&c,&d);
int perimeter=a+b+c+d;
printf("Perimeter of the Trapezoid = %d",perimeter);
}
#include<math.h>
int main()
{
printf("Enter the value of base:");
int a,b;
scanf("%d%d",&a,&b);
int c,d;
printf("Enter the value of side:");
scanf("%d%d",&c,&d);
int perimeter=a+b+c+d;
printf("Perimeter of the Trapezoid = %d",perimeter);
}
Input/Output:
Enter the value of base:4
3
Enter the value of side:7
9
Perimeter of the Trapezoid = 23
Program in C++
Here is the source code of the C++ Program to compute the perimeter of the Trapezoid.
3
Enter the value of side:7
9
Perimeter of the Trapezoid = 23
Program in C++
Here is the source code of the C++ Program to compute the perimeter 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 c,d;
cout<<"Enter the value of side:";
cin>>c;
cin>>d;
int perimeter=a+b+c+d;
cout<<"Perimeter of the Trapezoid = "<<perimeter;
}
Input/Output:#include<cmath>
using namespace std;
int main()
{
cout<<"Enter the value of base:";
int a,b;
cin>>a;
cin>>b;
int c,d;
cout<<"Enter the value of side:";
cin>>c;
cin>>d;
int perimeter=a+b+c+d;
cout<<"Perimeter of the Trapezoid = "<<perimeter;
}
Enter the value of base:9
12
Enter the value of side:7
8
Perimeter of the Trapezoid = 36
Program in Java
12
Enter the value of side:7
8
Perimeter of the Trapezoid = 36
Program in Java
Here is the source code of the Java Program to compute the perimeter of the Trapezoid.
Code:
import java.util.Scanner;
public class Perimeter_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 c,d;
System.out.println("Enter the value of side:");
c=cs.nextInt();
d=cs.nextInt();
int perimeter=a+b+c+d;
System.out.println("Perimeter of the Trapezoid = "+perimeter);
cs.close();
}
}
public class Perimeter_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 c,d;
System.out.println("Enter the value of side:");
c=cs.nextInt();
d=cs.nextInt();
int perimeter=a+b+c+d;
System.out.println("Perimeter of the Trapezoid = "+perimeter);
cs.close();
}
}
Input/Output:
Enter the value of base:
10
13
Enter the value of side:
19
23
Perimeter of the Trapezoid = 65
10
13
Enter the value of side:
19
23
Perimeter of the Trapezoid = 65
Program in Python
Here is the source code of the Python Program to compute the perimeter of the Trapezoid.
Code:
print("Enter the value of base:")
a=int(input())
b=int(input())
print("Enter the value of side:")
c=int(input())
d=int(input())
perimeter=a+b+c+d
print("Perimeter of the Trapezoid = ",perimeter)
Enter the value of base:
45
35
Enter the value of side:
7
10
Perimeter of the Trapezoid = 97
More:-
45
35
Enter the value of side:
7
10
Perimeter of the Trapezoid = 97
More:-
0 Comments
Please do not Enter any spam link in the comment box