- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find length of Diagonal of Hexagon in C++
In this problem, we are given an integer n denoting the length of the side of a regular hexagon. Our task is to Find length of Diagonal of Hexagon.
Problem Description: Here, we have the side of a regular hexagon. And we need to find the length of the diagonal of the hexagon.
Let’s take an example to understand the problem,
Input: a = 7
Output: 12.11
Solution Approach
To solve the problem and find the length of diagonal which is given by the mathematical formula,
Diagonal = 1.73 * a
Let’s derive the formula,
Here, we have a regular polygon of length a.
The angle between the diagonal and side is 600.
The ratio of (d/2)/a is equal to sin 60o
Sin 60o = d/ 2*a
0.866 = d/ 2*a
d = 0.866 * 2 * a
d = 1.73 * a
Program to illustrate the working of our solution,
Example
#include <iostream> using namespace std; int main() { float a = 12; float d = 1.73 * a; cout<<"The length of diagonal is "<<d; return 0; }
Output
The length of diagonal is 20.76
- Related Articles
- Area of hexagon with given diagonal length in C Program?
- C Program for area of hexagon with given diagonal length?
- Find the number of diagonal in hexagon.
- Diagonal of a Regular Hexagon in C++?
- Diagonal of a Regular Hexagon in C++ Program
- Area of a square from diagonal length in C++
- The length of a diagonal of a square is 8. Find the length of each side of the square.
- Find the length of diagonal of a rectangle whose sides are 12cm and 5cm.
- The area of a square is 11250 m2 find the length of its diagonal.
- Finding the length of the diagonal of a cuboid using JavaScript
- The side of a regular hexagon in below figure is denoted by ( l ). Express the perimeter of the hexagon using ( l ).(Hint : A regular hexagon has all its six sides equal in length.)"
- How to find Angle sum of a hexagon?
- C++ program to find the Area of the Largest Triangle inscribed in a Hexagon?
- The area of a square field is $frac{1}{4}$ hectare. Find the length of its diagonal in metres.
- If the length and breadth of a rectangle are ( 10 mathrm{~cm} ) and ( 20 mathrm{~cm} ), respectively, find the length of its diagonal.

Advertisements