C Articles - Page 78 of 134

C Program for area of hexagon with given diagonal length?

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

217 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 which is inscribed in equilateral triangle in C Program?

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

344 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

208 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 a triangle inscribed in a rectangle which is inscribed in an ellipse In C Program?

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 which is inscribed in a hexagon in C Program?

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

Angle between two Planes in 3D in C Program?

Aman Kumar
Updated on 30-Jul-2025 14:13:45

202 Views

In 3D geometry, planes are flat surfaces extending infinitely in space. When two planes intersect, they form a line, and the angle between them becomes an important geometric measure. In this article, we will learn how to calculate the angle between two planes in 3D space using a C program. The diagram below illustrates two planes intersecting in 3D space. These planes can be represented by the following equations: Equation P1: a1 * x + b1 * y + c1 * z + d1 = 0 P2: a2 * x + b2 * y + c2 * ... Read More

Alphanumeric Abbreviations of a String in C Program?

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

572 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

Adding one to number represented as array of digits in C Program?

Arnab Chakraborty
Updated on 20-Aug-2019 14:25:16

342 Views

In this section we will see one interesting problem. Suppose one number is given. We have to increase this number by 1. This is extremely simple task. But here we will place the number as an array. each digit of that number is placed as an element of the array. If the number is 512, then it will be stored as {5, 1, 2}. And also we have to increase the number using recursive approach. Let us see the algorithm to get the clear idea.Algorithmincrement(arr, n, index) −Initially the default value of index is 0 begin    if index < ... Read More

Advertisements