# Diagonal of a Regular Heptagon in C++ Program

C++Server Side ProgrammingProgramming

In this tutorial, we are going to learn how to find the diagonal of a regular heptagon.

We have to find the length of the diagonal of the regular heptagon using the given side. The length of the diagonal of a regular heptagon is 1.802 * s where s is the side of the heptagon.

## Example

Let's see the code.

Live Demo

#include <bits/stdc++.h>
using namespace std;
float heptagonDiagonal(float s) {
if (s < 0) {
return -1;
}
return 1.802 * s;
}
int main() {
float s = 7;
cout << heptagonDiagonal(s) << endl;
return 0;
}

## Output

If you run the above code, then you will get the following result.

12.614

## Conclusion

If you have any queries in the tutorial, mention them in the comment section.

Updated on 27-Jan-2021 12:31:07