Programming Articles

Page 994 of 2547

Program to calculate area of Circumcircle of an Equilateral Triangle

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 320 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 812 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 476 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 732 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 578 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 367 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 596 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

How to declaring pointer variables in C/C++?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 561 Views

A pointer is a variable that stores the memory address of another variable. To declare pointer variables in C, we use the asterisk (*) operator before the variable name during declaration. Syntax data_type *pointer_name; Where data_type is the type of variable the pointer will point to, and pointer_name is the name of the pointer variable. Basic Pointer Declaration and Usage Here's how to declare and use pointer variables in C − #include int main() { // A normal integer variable int ...

Read More

How to compare pointers in C/C++?

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

Pointers in C can be directly compared using relational operators to check their memory addresses. This allows us to determine equality, ordering, and relative positions of pointers in memory. Syntax pointer1 == pointer2 // Equality comparison pointer1 != pointer2 // Inequality comparison pointer1 < pointer2 // Less than comparison pointer1 > pointer2 // Greater than comparison pointer1 = pointer2 // Greater than or equal Pointer Comparison in C In C, we can compare pointers using relational operators ...

Read More
Showing 9931–9940 of 25,466 articles
« Prev 1 992 993 994 995 996 2547 Next »
Advertisements