C Articles - Page 88 of 134

Area of a n-sided regular polygon with given Radius in C Program?

sudhir sharma
Updated on 13-Aug-2019 08:27:29

413 Views

A polygon is a ‘n’ sided closed figure.N sided polygon means a polygon with n equal sides. The radius of a polygon is distance between center and vertex.In the figure we can see that the whole polygon can be divided into n equal polygonWe know, area of the triangle = (base * height)/2Area of the small triangle using trigonometric logic, area = r2*sin(t)cos(t) = (r2*sin(2t))/2So, area of the polygon:Area = n * (area of one triangle)= n*r2*sin(2t)/2 = n*r2*sin(360/n)/2Example#include #include int main() {    float r = 4 n = 12;    float area = ((r * r ... Read More

Area of a leaf inside a square in C Program?

sudhir sharma
Updated on 09-Aug-2019 07:07:47

324 Views

To find the area of leaf inside a square, we need to split it into parts and find the area of parts and then add the areas to find the area of leaf.To calculate the area we are splitting the leaf into two parts.To find the area of 1st part AECA, we will find the area of quad circle AECDA and subtract the area of triangle ACDA from it.area of a Quadrant = 1⁄4 *(π*r2) whereπ = 22/7 or 3.141.area of a right angle triangle= 1⁄2*B*H = ½ a2Example#include #define PI 3.14159265 int main() {    float a = 12.3; ... Read More

C Program for Area of a square inscribed in a circle which is inscribed in a hexagon?

sudhir sharma
Updated on 09-Aug-2019 06:57:01

227 Views

Given, A square that is inscribed within a circle that is inscribed in a regular hexagon and we need to find the area of the square, for that we need to find the relation of the side of square and the side of the hexagon.The mathematical formula for the radius of circle inscribed within the hexagon is, r=A√3/2Since, the diagonal of square is equal to diameter of the circle, so the relation between the radius and side is, a=√rBased on the side of hexagon, a = √3A/√2So, Area of the Square, Area=a2 = (√3A/√2)2Example#include #include int main() { ... Read More

Area of decagon inscribed within the circle in C Program?

sudhir sharma
Updated on 09-Aug-2019 06:43:58

305 Views

A regular decagon is a ten sided polygon with all sides and angles equal. And here we need to find the area of a decagon that is inscribed inside a circle using the radius of the circle r, Mathematical formula for the side of the decagon inscribed in the circle, a = r√(2-2cos36o)(Using cosine rules)Formula for finding area of decagon, Area = 5*a2*(√5+2√5)/2 Area = 5 *(r√(2-2cos36))^2*(√5+2√5)/2 Area = (5r2*(3-√5)*(√5+2√5))/4Using this formula in a program, Example#include #include int main() {    float r = 8;    float area = (5 * pow(r, 2) * (3 - sqrt(5))* (sqrt(5) ... Read More

Area of hexagon with given diagonal length in C Program?

sudhir sharma
Updated on 09-Aug-2019 06:40:03

1K+ Views

A Hexagon is a closed figure of 6 side and a regular hexagon is the one which has all six sides equal and angle equal. For finding the area of hexagon, we are given only the length of its diagonal i.e d.The interior angles of Hexagon are of 120 degrees each and the sum of all angles of a Hexagon is 720 degrees.The formula to find the area of hexagon with side length a, Area = (3a2 √3) / 2.Since all sides are of same size and angle is 120 degrees, d = 2a or a = d/2By putting the ... Read More

Area of largest Circle inscribed in N-sided Regular polygon in C Program?

sudhir sharma
Updated on 09-Aug-2019 06:34:34

214 Views

An n-sided regular polygon inscribed in a circle, the radius of this circle is given by the formula, r = a/(2*tan(180/n))Suppose a polygon have 6 faces i.e., a hexagon and as we know mathematically that the angle is 30 degreeSo the radius of circle will be (a / (2*tan(30)))Therefore, r = a√3/2We see the polygon can be divided into N equal triangles. Looking into one of the triangles, we see that the whole angle at the center can be divided into = 360/NSo, angle x = 180/n Now, tan(x) = (a / 2) * r So, r = a / ... Read More

Area of Incircle of a Right Angled Triangle in C Program?

sudhir sharma
Updated on 09-Aug-2019 06:28:56

2K+ Views

To find the area of a circle inside a right angled triangle, we have the formula to find the radius of the right angled triangle, r = ( P + B – H ) / 2.Given the P, B and H are the perpendicular, base and hypotenuse respectively of a right angled triangle.Area of a circle is given by the formula, Area = π*r2where π = 22 / 7 or 3.14 and r is the radius of the circle.Hence the area of the incircle will be given by the formula, Area = π* ((P + B – H) / 2)2.Example#include ... Read More

Print the string after the specified character has occurred given no. of times in C Program

Sunidhi Bansal
Updated on 08-Aug-2019 10:18:04

764 Views

Task is to print the given after the specified character occurrence for given number of times which is specified by the userInput : string = {“I am harsh vaid “}    Char =’a’    Count =2 Output : rsh vaidIt means user specified character ‘a’ and its occurrence 2 so the output string should be displayed after two occurrences of a.AlgorithmSTART Step 1 -> input character in ch(e.g. ‘a’) and count(e.g. 2) as int Step 2 -> declare and initialize n with size of a string by sizeof(string)/sizeof(string[0]) Step 3 - > Loop For i to 0 and i 0 ... Read More

C Program for Print the pattern by using one loop

Sunidhi Bansal
Updated on 08-Aug-2019 09:27:32

4K+ Views

The challenge is to display the pattern using one loop only and with continue statement.AlgorithSTART Step 1 -> declare start variables i and j to 0 with number of rows in n to 6 Step 2 -> Loop For i=1 and i

Print triplets with sum less than or equal to k in C Program

Sunidhi Bansal
Updated on 01-Jul-2020 08:08:03

176 Views

Given array with set of elements and the task is to find out set with exactly three elements having sum less than or equals to k.Input − arr[]= {1, 2, 3, 8, 5, 4}Output − set → {1, 2, 3} {1, 2, 5} {1, 2, 4} {1, 3, 5} {1, 3, 4} {1, 5, 4} {2, 3, 5} {2, 3, 4}In this, first task is to calculate the size of array depending upon which for loop of i is iterated till size-2 and for loop of j is iterated till size-1 and for loop of k is iterated till sizeAlgorithSTART Step 1 ... Read More

Advertisements