Diagonal of a Regular Heptagon in C++?

To find the length of the diagonal we put the value of side in 2*side*sin (900/14). The value of sin (900/14) = 0.9.


Let us see the following implementation to get the regular Heptagon diagonal from its side −

 Live Demo

#include <iostream>
using namespace std;
int main(){
   float side = 12;
   if (side < 0)
      return -1;
   float diagonal = 2*side*0.9;
   cout << "The diagonal of the heptagon = "<<diagonal<< endl;
   return 0;


The above code will produce the following output −

The diagonal of the heptagon = 21.6