
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Diagonal of a Regular Hexagon in C++
The regular hexagons are comprised of six equilateral triangles so the diagonal of a regular hexagon would be 2*side.
Example
Let us see the following implementation to get the regular Heptagon diagonal from its side −
#include <iostream> using namespace std; int main(){ float side = 12; if (side < 0) return -1; float diagonal = 2*side; cout << "The diagonal of the regular hexagon = "<<diagonal<< endl; return 0; }
Output
The above code will produce the following output −
The diagonal of the hexagon = 24
Advertisements