C Articles

Page 77 of 96

Program to calculate Area Of Octagon

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 919 Views

An octagon is a polygon with eight sides. To calculate the area of a regular octagon, we use a specific mathematical formula based on the side length. Syntax Area = 2 * (1 + √2) * side² Where side is the length of one side of the regular octagon. Formula Explanation The area of a regular octagon can be calculated using the formula − Area = 2 * (1 + √2) * a² Where: a is the side length of the octagon √2 is approximately 1.414 The coefficient 2 * ...

Read More

Program to calculate area of Enneagon

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 202 Views

An enneagon (also known as nonagon) is a polygon with 9 sides. To calculate the area of an enneagon, we use a specific mathematical formula based on the side length. Syntax Area = (a² × 9) / (4 × tan(20°)) Area ≈ 6.1818 × a² Where a is the length of each side of the enneagon. ...

Read More

Program to calculate area of Circumcircle of an Equilateral Triangle

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 299 Views

A circumcircle is a circle that passes through all vertices of a polygon. For an equilateral triangle, the circumcircle can be calculated using the relationship between the triangle's side length and the circle's radius. Syntax Area = (π × a²) / 3 where a = side length of equilateral triangle Mathematical Formula The area of the circumcircle of an equilateral triangle with side length a is given by − Area = (π × a²) / 3 This formula is derived from the fact that the circumradius R of an equilateral triangle is ...

Read More

Program to calculate the area of an Circle inscribed in a Square

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 796 Views

A circle inscribed in a square is a circle which touches all four sides of the square. The diameter of the inscribed circle is equal to the side of the square. The area can be calculated using the formula (π/4) × a² where 'a' is the length of side of square. Square with Inscribed Circle r = a/2 Side = a ...

Read More

Program to calculate area and volume of a Tetrahedron

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 456 Views

A tetrahedron is a pyramid with a triangular base i.e. it has a base that is a triangle and each side has a triangle. All the three triangles converge to a point. As shown in the figure − Base (triangle) Apex a The code to find the area and volume of tetrahedron uses the ...

Read More

Program to calculate area and perimeter of Trapezium

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 712 Views

A trapezium is a quadrilateral that has at least one pair of parallel sides. The area and perimeter of a trapezium can be calculated using specific mathematical formulas. Syntax Perimeter = side1 + side2 + side3 + side4 Area = 0.5 * (parallel_side1 + parallel_side2) * height Formula Explanation Perimeter: Sum of all four sides of the trapezium Area: Half the product of the sum of parallel sides and the perpendicular distance between them Example This program calculates the area and perimeter of a trapezium using the given measurements − ...

Read More

Program to calculate area and perimeter of equilateral triangle

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 569 Views

An equilateral triangle is a closed figure with three equal sides. We can calculate its area and perimeter using mathematical formulas that involve the side length. Syntax Area = (√3/4) * side2 Perimeter = 3 * side Formulas For an equilateral triangle with side length a − Area of equilateral triangle = (√3)/4 * a2 Perimeter of equilateral triangle = 3 * a Logic of Code To find the area of an equilateral triangle, the program uses sqrt() function from the math library to calculate the square root of ...

Read More

Program to find the perimeter of a rhombus using diagonals

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 337 Views

A rhombus is a quadrilateral where all four sides have equal length. The perimeter of a rhombus can be calculated using two methods: adding all sides or using the diagonal lengths. When using diagonals, we apply the mathematical relationship between the diagonals and side length. Syntax perimeter = 2 * sqrt(pow(d1, 2) + pow(d2, 2)); Where d1 and d2 are the lengths of the two diagonals. Mathematical Formula The perimeter of a rhombus using diagonals is calculated as: Perimeter = 2 × √(d1² + d2²) ...

Read More

Why do we check for a NULL pointer before deleting in C/C++?

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 585 Views

In C programming, checking for a NULL pointer before calling free() is often seen in code, but it's technically unnecessary. The free() function is designed to safely handle NULL pointers by doing nothing when passed a NULL value. Syntax void free(void *ptr); Why NULL Check is Unnecessary According to the C standard, free(NULL) is guaranteed to be a no-op (no operation). This means the following code is redundant − #include #include int main() { int *ptr = NULL; ...

Read More

Is it safe to delete a void pointer in C/C++?

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 15-Mar-2026 1K+ Views

The void pointer is a pointer which is not associated with any data type. It points to some data location in storage means points to the address of variables. It is also called general purpose pointer. However, deleting void pointers requires careful consideration for memory safety. Is It Safe to Delete a Void Pointer in C/C++? It is not safe to delete a void pointer directly because the compiler needs to know the exact type to call the appropriate destructor and determine the correct memory size to deallocate. Deleting without proper type information can lead to undefined behavior. ...

Read More
Showing 761–770 of 953 articles
« Prev 1 75 76 77 78 79 96 Next »
Advertisements