- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# C++ program to find the side of the Octagon inscribed within the square

In this tutorial, we will be discussing a program to find the side of the octagon inscribed within a given square.

For this, we will be given with the side of a square and our task is to find the side of the largest octagon that can be inscribed in it.

Finding the relation between the sides of the square and the octagon, we find the formula for the side of the octagon

**side of square/(√2 + 1)**

## Example

#include <bits/stdc++.h> using namespace std; //calculating the side of the octagon float calc_oside(float a) { if (a < 0) return -1; float s = a / (sqrt(2) + 1); return s; } int main() { float a = 41; cout << calc_oside(a) << endl; return 0; }

## Output

16.9828

- Related Articles
- C Program for area of decagon inscribed within the circle?
- Area of decagon inscribed within the circle in C Program?
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within a hexagon in C?
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within an ellipse in C?
- The side of a square is 10 cm. Find the area of circumscribed and inscribed circles.
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within a hexagon?
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within an ellipse?
- A square, whose side is 4 metres, has its corners cut away so as to form an octagon with all sides equal. Find the length of each side of the octagon (in metres).
- Biggest Reuleaux Triangle inscribed within a square inscribed in a semicircle in C?
- Find the area of the circle that can be inscribed in a square of side $6 cm$.
- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle in C?
- Area of circle inscribed within rhombus in C Program?
- Biggest Reuleaux Triangle within a Square which is inscribed within a Circle in C?
- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle?
- Biggest Reuleaux Triangle within a Square which is inscribed within a Circle?

Advertisements