Articles on Trending Technologies

Technical articles with clear explanations and examples

PHP Program to Calculate the Average of an Array of Numbers

PHP
AYUSH MISHRA
AYUSH MISHRA
Updated on 15-Mar-2026 899 Views

The average or mean of an array is a basic mathematical operation in programming. The average is used in analytics, finance, and reporting. One of the real-life applications is a website that calculates the average rating of a product or the average score of a test. In this article, we are going to learn how we can calculate the average of an array of numbers in PHP using different approaches. What is Average? The average is obtained by calculating the sum of all elements in an array and then dividing the sum by the total number of elements ...

Read More

Program to calculate area and perimeter of Trapezium

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 753 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 582 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

PHP Program to Find the Percentage of a Number

PHP
AYUSH MISHRA
AYUSH MISHRA
Updated on 15-Mar-2026 4K+ Views

In this problem, we are given a number and a percentage value, and we have to find the percentage of the given number. In this article, we are going to learn how we can calculate the percentage of a number in PHP using different approaches. Understanding the Formula To find the percentage of a number, we use the formula: (Number × Percentage) / 100 Example: The percentage of 300 with respect to 40% is calculated as (300 × 40) / 100 = 120. Number: 300 Percentage: 40% ...

Read More

Program to find the perimeter of a rhombus using diagonals

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 382 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

PHP Program to Calculate Simple Interest and Compound Interest

PHP
AYUSH MISHRA
AYUSH MISHRA
Updated on 15-Mar-2026 4K+ Views

Simple Interest is the interest calculated only on the principal amount, while Compound Interest is calculated on both the principal and accumulated interest from previous periods. This article demonstrates how to calculate both types of interest using PHP. Simple Interest Formula The formula for calculating Simple Interest is − Simple Interest (SI) = P × R × T / 100 Where: P is the principal amount R is the interest rate per annum T is the time period in years ...

Read More

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

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 599 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

Php echo if two conditions are true

PHP
saba Khan
saba Khan
Updated on 15-Mar-2026 332 Views

In PHP, you can use the && (AND) operator with if statements to check if two conditions are both true. The code block executes only when both conditions evaluate to true − if either condition is false, the block is skipped. PHP also has an "and" keyword similar to &&, but it has lower precedence and can behave differently in complex expressions. It's recommended to use && for better clarity and consistency. Basic Syntax if (condition1 && condition2) { echo "Both conditions are true!"; } The code block executes only ...

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 Add Two Numbers in PHP Program?

PHP
AYUSH MISHRA
AYUSH MISHRA
Updated on 15-Mar-2026 23K+ Views

In PHP, adding two numbers is a fundamental arithmetic operation that can be performed using various approaches. This article demonstrates different methods to add two numbers in PHP programming. Basic Addition Example Before exploring different approaches, let's look at a simple example − Result: 20 The addition of 8 + 12 gives 20 as the result. Now let's explore different approaches to implement this operation. Method 1: Direct Addition This is the simplest approach using the plus (+) operator directly between two variables ? Syntax ...

Read More
Showing 21791–21800 of 61,297 articles
Advertisements