Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by AYUSH MISHRA
Page 7 of 12
PHP Program for Binary to Decimal Conversion
Binary to decimal conversion is the process of converting a binary number (base-2 number using only 0s and 1s) into its equivalent decimal number (base-10 form). In this article, we will learn how to convert binary numbers to decimal form in PHP using different approaches. How Binary to Decimal Conversion Works To convert a binary number to decimal, multiply each binary digit by 2 raised to the power of its position (starting from 0 on the right), then sum all results ? Binary to Decimal Conversion: 1011 Position: ...
Read MorePHP Program to Count Vowels in a String
A string is a sequence of characters, including alphabets, numbers, and symbols. In this tutorial, we are going to learn how we can count the number of vowels in a given string in PHP using different approaches. Vowels in English are a, e, i, o, u, and they can be either uppercase or lowercase. What is a Vowel? Vowels are alphabetic characters that represent specific speech sounds. There are a total of five vowels, both uppercase and lowercase in the English language: a, e, i, o, u A, E, I, O, U Example 1 ...
Read MoreHow to Check If Two Arrays are Equal in PHP?
When working with arrays in PHP, you often need to compare them to check if they contain the same elements. Array equality can mean different things − same elements in same order, same elements regardless of order, or strict type matching. This article explores different approaches to check if two arrays are equal in PHP. Using the == Operator The == operator provides a loose comparison, checking if arrays have the same elements in the same order without strict type checking ? The arrays are equal Using the === Operator ...
Read MorePHP program to find the perimeter of rectangle
A rectangle is a closed two-dimensional figure with 4 sides where opposite sides are equal and parallel. The perimeter is the total distance around the rectangle, calculated by adding all four sides. In this tutorial, we'll learn different PHP approaches to calculate rectangle perimeter. Length Breadth Length Breadth Formula The formula for calculating rectangle perimeter is − Perimeter = 2 × (Length + Breadth) Where length is the horizontal distance and breadth is the vertical distance. Direct Formula Approach The ...
Read MorePHP Program to Check if a Number is an Armstrong Number
An Armstrong number is a number in which the sum of its digits raised to the power of the number of digits is equal to the number itself. In this article, we will discuss how to check if a given number is an Armstrong number using PHP. Examples Let's understand Armstrong numbers with some examples ? Example 1: 9474 This is a four-digit number with digits 9, 4, 7, and 4. 9474 = 9⁴ + 4⁴ + 7⁴ + 4⁴ = 6561 + 256 + 2401 + 256 ...
Read MoreHow to Add Elements to the End of an Array in PHP
Arrays are linear data structures used to handle data in programming. Sometimes while dealing with arrays we need to add new elements to an existing array. In this article, we will discuss several methods to add elements to the end of an array in PHP, complete with code examples and outputs. Following are different approaches to adding elements to an array − Using Square Brackets [] The simplest way to add an element to the end of an array in PHP is by using square brackets []. This syntax is suitable when you want to add only ...
Read MoreFind the number that appears once, and the other numbers twice in Java
In this problem, we are given an array of integers. In the given array, each element occurs two times except one element, which occurs only once. We have to find the number that appears only once. In this article, we are going to learn how we can find the number that appears once, and all other numbers appear twice in Java. Scenario 1 All other numbers except 4 occur twice, so 4 is the only number that appears only once. Input: [ 1, 2, 3, 3, 2, 4, 1, 5, 5] Output: 4 Scenario 2 All other numbers except ...
Read MoreC++ Program to Rotate Array Left by One Position
Rotating an array means shifting the elements of an array in a specific direction while maintaining their relative order. For example, if the array {6, 12, 18, 24, 30} is rotating it left once will result in {12, 18, 24, 30, 6}. In this article, we are given an array and need to shift all elements one step to the left, with the first element moving to the last position. Example Here is an example of left rotation of elements in array by one place. Input: array = {5, 10, 15, 20, 25} Output: array = {10, 15, ...
Read MoreC++ Program to Find Sum of Leaf Node in Binary Tree
We can find the sum of leaf nodes in a binary tree using an iterative and a recursive approach. This problem has many real-life applications, such as analyzing hierarchies, calculating final results in decision trees, or summing final nodes in various kinds of trees used in computer algorithms. In this article, we are going to learn how can find the sum of all leaf nodes in a binary tree in the C++ language. What are Leaf Nodes in a Binary Tree? The leaf nodes of a binary tree are the nodes that do not have any children. Both the ...
Read MoreKth largest Element in a 2D matrix where each row and column is sorted in C++
Finding the Kth largest element in a 2D matrix where each row and column is sorted is a common problem in computer science. This problem has many real-life applications, such as a ranking system, where we need to find the Kth highest score in a sorted dataset. In this article, we are going to discuss how we can find the Kth largest element in a 2D matrix e where each row and column is in sorted order in the C++ language. What is the Kth Largest Element? The Kth largest element refers to an element that is placed at ...
Read More