

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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++ Program
In this tutorial, we are going to learn how to find the diagonal of a regular hexagon.
We have to find the length of the diagonal of the regular hexagon using the given side. The length of the diagonal of a regular hexagon is 1.73 * s where s is the side of the hexagon.
Example
Let's see the code.
#include <bits/stdc++.h> using namespace std; float hexagonDiagonal(float s) { if (s < 0) { return -1; } return 1.73 * s; } int main() { float s = 7; cout << hexagonDiagonal(s) << endl; return 0; }
Output
If you run the above code, then you will get the following result.
12.11
Conclusion
If you have any queries in the tutorial, mention them in the comment section.
- Related Questions & Answers
- Diagonal of a Regular Hexagon in C++?\n
- Area of hexagon with given diagonal length in C Program?
- Find length of Diagonal of Hexagon in C++
- Diagonal of a Regular Heptagon in C++ Program
- Diagonal of a Regular Pentagon in C++ Program
- C Program for area of hexagon with given diagonal length?
- Area of a circle inscribed in a regular hexagon?
- Diagonal of a Regular Heptagon in C++?
- Diagonal of a Regular Pentagon in C++?
- Program to find diagonal sum of a matrix in Python
- C++ program to find the Area of the Largest Triangle inscribed in a Hexagon?
- Program to print a matrix in Diagonal Pattern.
- Area of a square inscribed in a circle which is inscribed in a hexagon in C Program?
- C Program for Area of a square inscribed in a circle which is inscribed in a hexagon?
- Diagonal product of a matrix - JavaScript
Advertisements