Area of Largest Circle Inscribed in N-Sided Regular Polygon in C Program

Arnab Chakraborty
Updated on 20-Aug-2019 12:29:48

232 Views

Here we will see how to get the area of the circle which is inscribed in N-sided regular polygon. The N (number of sides) are given, and each side of the polygon is ‘a’The approach is simple. One N sided polygon can be divided into N equal triangles, the whole angle for each triangle in center is 360/N, so −Example#include #include using namespace std; float area(float n, float a) {    if (n < 0 || a < 0 ) //if the valuse are negative it is invalid       return -1;    float r = a/(2.0*tan((180/n) ... Read More

Calculate Area of Hexagon with Given Diagonal Length in C

Arnab Chakraborty
Updated on 20-Aug-2019 12:23:31

395 Views

Here we will see how to get the area of one hexagon using diagonal length. The diagonal length of the hexagon is d.The interior angles of a regular hexagon are 120° each. The sum of all interior angles are 720°. If the diagonal is d, then area is −Example#include #include using namespace std; float area(float d) {    if (d < 0) //if d is negative it is invalid       return -1;    float area = (3 * sqrt(3) * d*d)/8.0;    return area; } int main() {    float r = 10;    cout

C Program for Area of Decagon Inscribed Within the Circle

Arnab Chakraborty
Updated on 20-Aug-2019 12:19:06

225 Views

Here we will see how to get the area of decagon which is present inside the circle. The radius is given. The side of the decagon is ‘a’.As we know that the side of the decagon is like below −So the area is −Example#include #include using namespace std; float area(float r) {    if (r < 0) //if r is negative it is invalid       return -1;    float area = (5 * pow(r, 2) * (3 - sqrt(5)) * (sqrt(5) + (2 * sqrt(5)))) / 4;    return area; } int main() {    float r = 8;    cout

Area of Circumcircle of a Right Angled Triangle in C Program

Arnab Chakraborty
Updated on 20-Aug-2019 12:14:41

218 Views

Here we will see how to get the area of circumcircle of a right angled triangle. The hypotenuse of the triangle is forming the diameter of the circle. So if the hypotenuse is h, then radius is h/2So the area is −Example Code#include #include using namespace std; float area(float h) {    if (h < 0) //if h is negative it is invalid       return -1;    float area = 3.1415 * (h/2) * (h/2);    return area; } int main() {    float h = 8;    cout

Area of Circle Inscribed in Equilateral Triangle in C Program

Arnab Chakraborty
Updated on 20-Aug-2019 12:09:05

345 Views

Here we will see the area of circle which is inscribed in an equilateral triangle. The sides of the triangle are ‘a’.The area of equilateral triangle −The semi-perimeter of the triangle is −So the radius of the circle is −Example#include #include using namespace std; float area(float a) {    if (a < 0 ) //if the value is negative it is invalid       return -1;    float area = 3.1415 * (a/(2*sqrt(3))) * (a/(2*sqrt(3)));    return area; } int main() {    float a = 4;    cout

Area of Circle Inscribed Within Rhombus in C Program

Arnab Chakraborty
Updated on 20-Aug-2019 12:02:47

209 Views

Here we will see the area of circle which is inscribed in a rhombus. The diagonals of the rhombus are ‘a’ and ‘b’. The radius of the circle is h.Two diagonals are creating four equal triangles. Each triangle is right-angled triangle, so their area is −Each side of the rhombus is the hypotenuses −So the area of the circle is −Example#include #include using namespace std; float area(float a, float b) {    if (a < 0 || b < 0) //if the values are negative it is invalid       return -1;    float area = (3.1415 ... Read More

Area of Triangle Inscribed in Rectangle and Ellipse in C

Arnab Chakraborty
Updated on 20-Aug-2019 11:56:52

110 Views

Here we will see the area of a triangle which in inscribed in one rectangle and that circle is inscribed in an ellipse. The half of the major and minor axis are ‘a’ and ‘b’ respectively. Suppose the length of the rectangle is ‘l’ and breadth is ‘h’We know that the area of the rectangle in an ellipse is −The area of the triangle is −Example#include #include using namespace std; float area(float a, float b) {    if (a < 0 || b < 0) //if the values are negative it is invalid       return -1; ... Read More

Area of a Square Inscribed in a Circle within a Hexagon in C

Arnab Chakraborty
Updated on 20-Aug-2019 11:46:54

146 Views

Here we will see the area of a square which in inscribed in one circle and that circle is inscribed in a hexagon. The side of the square is ‘a’. The radius of the circle is ‘r’, and the side of the hexagon is ‘A’. The diagram will be like below.We know that the radius of a circle inscribed in a hexagon is −Also the radius of the circle is half of the diagonal of the square. So −Then we can say −Then the area will be −Example#include #include using namespace std; float area(float A) { //A is ... Read More

Alphanumeric Abbreviations of a String in C Program

Arnab Chakraborty
Updated on 20-Aug-2019 11:31:43

575 Views

Here we will see one interesting problem related to alphanumeric abbreviation of a given string. The string length is less than 10. We will print all alphanumeric abbreviations.The alphanumeric abbreviation is in the form of characters mixed with the digits. The value of that digit is number of characters that are missed. There may be any number of skipped substrings. No two substrings are adjacent to each other. Let us see the algorithm to get the idea.AlgorithmprintAbbreviation(s, index, max, str) −begin    if index is same as max, then       print str    end if    add s[index] ... Read More

C Program for Rat in a Maze using Backtracking

sudhir sharma
Updated on 20-Aug-2019 10:25:14

3K+ Views

Rat in a maze is also one popular problem that utilizes backtracking. IA maze is a 2D matrix in which some cells are blocked. One of the cells is the source cell, from where we have to start. And another one of them is the destination, where we have to reach. We have to find a path from the source to the destination without moving into any of the blocked cell. A picture of an unsolved maze is shown below.And this is its solution.To solve this puzzle, we first start with the source cell and move in a direction where ... Read More

Advertisements