Problem statement:- Program to compute the area and perimeter of the Heptagon.
Formula:
Area Of Heptagon(A):
Formula:
Area Of Heptagon(A):
where a=side length of the Heptagon
Perimeter of Heptagon(P):
P
=
7a
where a=side length of the Heptagon
P
=
7a
Data requirement:-
Input Data:- a
Output Data:- area, perimeter
Output Data:- area, perimeter
Program in C
Here is the source code of the C Program to compute the area and perimeter of the Heptagon.
Code:
#include<stdio.h>
#include<math.h>
int main()
{
printf("Enter the length of the side:");
int a;
scanf("%d",&a);
double area=3.634*pow(a,2);
int perimeter=(7*a);
printf("Area of the Heptagon = %0.2lf\n",area);
printf("Perimeter of the Heptagon = %d",perimeter);
}
#include<math.h>
int main()
{
printf("Enter the length of the side:");
int a;
scanf("%d",&a);
double area=3.634*pow(a,2);
int perimeter=(7*a);
printf("Area of the Heptagon = %0.2lf\n",area);
printf("Perimeter of the Heptagon = %d",perimeter);
}
Input/Output:
Enter the length of the side:5
Area of the Heptagon = 90.85
Perimeter of the Heptagon = 35
Program in C++
Here is the source code of the C++ Program to compute the area and perimeter of the Heptagon.
Area of the Heptagon = 90.85
Perimeter of the Heptagon = 35
Program in C++
Here is the source code of the C++ Program to compute the area and perimeter of the Heptagon.
Code:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
cout<<"Enter the length of the side:";
int a;
cin>>a;
double area=3.634*pow(a,2);
int perimeter=(7*a);
cout<<"Area of the Heptagon = "<<area;
cout<<"\nPerimeter of the Heptagon = "<<perimeter;
}
Input/Output:#include<cmath>
using namespace std;
int main()
{
cout<<"Enter the length of the side:";
int a;
cin>>a;
double area=3.634*pow(a,2);
int perimeter=(7*a);
cout<<"Area of the Heptagon = "<<area;
cout<<"\nPerimeter of the Heptagon = "<<perimeter;
}
Enter the length of the side:7
Area of the Heptagon = 178.066
Perimeter of the Heptagon = 49
Program in Java
Area of the Heptagon = 178.066
Perimeter of the Heptagon = 49
Program in Java
Here is the source code of the Java Program to compute the area and perimeter of the Heptagon.
Code:
import java.util.Scanner;
public class Area_Perimeter_Heptagon {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
System.out.println("Enter the length of the side:");
int a=cs.nextInt();
double area=3.634*Math.pow(a,2);
int perimeter=(7*a);
System.out.println("Area of the Heptagon = "+area);
System.out.println("Perimeter of the Heptagon = "+perimeter);
cs.close();
}
}
Input/Output:public class Area_Perimeter_Heptagon {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
System.out.println("Enter the length of the side:");
int a=cs.nextInt();
double area=3.634*Math.pow(a,2);
int perimeter=(7*a);
System.out.println("Area of the Heptagon = "+area);
System.out.println("Perimeter of the Heptagon = "+perimeter);
cs.close();
}
}
Enter the length of the side:
10
Area of the Heptagon = 363.4
Perimeter of the Heptagon = 70
10
Area of the Heptagon = 363.4
Perimeter of the Heptagon = 70
Program in Python
Here is the source code of the Python Program to compute the area and perimeter of the Heptagon.
Code:
import math
print("Enter the length of the side:")
a=int(input())
area=3.634*pow(a,2)
perimeter=(7*a)
print("Area of the Heptagon = ",area)
print("Perimeter of the Heptagon= ",perimeter)
Enter the length of the side:
13
Area of the Heptagon = 614.146
Perimeter of the Heptagon= 91
13
Area of the Heptagon = 614.146
Perimeter of the Heptagon= 91
Most Recommend Questions:-
More Questions:-
0 Comments
Please do not Enter any spam link in the comment box