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
Articles by AYUSH MISHRA
Page 4 of 12
Sort an array which contain 1 to n values
Sorting an array containing values from 1 to n means arranging the integers in their natural ascending order. This type of sorting problem is commonly encountered in competitive programming (for solving complex problems), where the array is guaranteed to have integers ranging from 1 to n. In this article, we will explore various approaches to solving this problem. In this problem, we are given an array containing values ranging from 1 to n in random order. Our goal is to sort the array in ascending order. Example 1 Input: int array[] = {3, 1, 2, ...
Read MoreC++ program to find the sum of elements between two given indices in array
Finding the sum of elements between two given indices in an array is a common operation in programming. In C++, there are multiple ways to calculate the sum of elements between two given indices in C++. In this article, we are going to discuss various approaches to calculating the sum of elements between two indices in an array using C++. How to Find the Sum of Elements Between Two Indices? In this problem, we are given an array and two indices, L and R, and we have to find the sum of elements from index L and R (both L ...
Read MoreC++ Program to Rotate Array Right by One Position
Rotating an array means shifting its elements in a specific direction while maintaining their relative order. In this article, we will rotate an array right by one position using C++. For example, if the array is {4, 8, 15, 16, 23}, rotating it right once will result in {23, 4, 8, 15, 16}. We are given an array and need to shift all elements one step to the right, with the last element moving to the first position. Example 1 Input:array = {10, 20, 30, 40, 50} Output:array = {50, 10, ...
Read MoreC++ Program to Count the Sum of Numbers in a String
In this problem, we are given a string containing alphanumeric characters, and the task is to extract all the numbers from the string and compute their sum. The numbers may appear anywhere within the string, and we need to identify them and add them together. In this article, we are going to explore different approaches to solving this problem in C++.Example 1Input: str = "anshu123ayush45anshu"Output: Sum = 174Explanation:The numbers extracted from the string are 123, 45, and 6. Their sum is 123 + 45 + 6 = 174.Example 2Input: str = "1abc2def34ghi56jkl"Output: Sum = 93Explanation:The numbers extracted from the string ...
Read MoreCheck if given four points form a square using C++
A square is a four-sided polygon with all sides equal and all angles equal to 90 degrees. In computational geometry, determining whether four given points form a square is a common problem. In this article, we will discuss multiple approaches to check whether four given points in a 2D plane form a square using C++. When can a four-sided polygon be called a Square? If we are given four points, we have to determine whether it is a square or not. To determine if four points (A, B, C, D) form a square, the given conditions below must be satisfied: ...
Read MoreC++ program to calculate area of circle
The area of a circle is a fundamental mathematical concept that can be easily calculated using a simple formula. In C++, there are multiple ways to find the area of a circle. In this article, we are going to discuss various approaches to calculating the area of a circle in C++. How to Find the Area of a Circle? The formula for finding the area of a circle with a given radius r is: Area = π × r × r Example 1 Input: r = 5 Output: 78.54 Explanation: ...
Read MorePython Program for Sum of first N even numbers
The sum of the first N even numbers is a mathematical operation. In this operation, we add up the firstN even numbers. In Python, there are multiple ways to calculate this sum. In this article, we are going to learn and discuss various approaches to finding the sum of the first N even numbers in Python. Finding the Sum of the First N Even Numbers The formula for finding the sum of the first N even numbers is: Sum = N * (N + 1) Example 1Let's look at a scenario where N=5, The first 5 even numbers ...
Read MorePython Program to find area of square
A square is a closed two-dimensional figure having 4 equal sides. Each angle of a square is 90 degrees. The area of a square is the space enclosed within its four sides. In this problem, we are given the side of a square, and we have to find the area of the square. In this tutorial, we are going to find the area of a given square in Python using different approaches. Example 1 Input: side = 6 units Output: 36 square units Using the formula to calculate the area of the square: side × side = 6 × ...
Read MoreHow to Add Two Numbers in PHP Program?
Problem Description In this problem, we are given two numbers, and we have to find the value obtained after adding one number to another. In this article, we are going to learn how we can add two numbers in PHP using different approaches. Example 1 Input $number1 = 8; $number2 = 12; Output 20 Explanation The addition of $number1 + $number2, i.e., 8 + 12, will give 20 as result. Example 2 Input $number1 = 10; $number2 = 10; Output 20 Explanation The addition of $number1 + $number2, i.e., 10 + 10, will result in 20. Below ...
Read MorePython Program to Calculate nCr and nPr
In combinatorics, nCr and nPr are essential formulas used to calculate combinations and permutations. They represent the number of ways to select and arrange objects from a set. nCr refers to combinations, where order does not matter, while nPr refers to permutations, where order does matter. The permutation refers to the arrangement of objects in a specific order.A combination refers to the selection of objects without taking order in reference. In this article, we are going to learn how we can calculate nCr and nPr in Python using different approaches. The formula for nCr and nPr The formulas ...
Read More