Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Diagonal of a Regular Pentagon in C++ Program
In this tutorial, we are going to learn how to find the diagonal of a regular pentagon.
We have to find the length of the diagonal of the regular pentagon using the given side. The length of the diagonal of a regular pentagon is 1.22 * s where s is the side of the pentagon.
Example
Let's see the code.
#include <bits/stdc++.h>
using namespace std;
float pentagonDiagonal(float s) {
if (s < 0) {
return -1;
}
return 1.22 * s;
}
int main() {
float s = 7;
cout << pentagonDiagonal(s) << endl;
return 0;
}
Output
8.54
Conclusion
If you have any queries in the tutorial, mention them in the comment section.
Advertisements
