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 4 of 12
JavaScript Program to Find the average of all positive numbers in an array
In this article, we will learn how to find the average of all positive numbers in an array using JavaScript, along with examples to demonstrate the implementation. We are given an array of integers, which may contain both negative and positive numbers. Our task is to calculate the average of all the positive numbers in the array. Problem Description The goal is to compute the average of all positive numbers in a given array. This involves summing up the positive numbers and dividing the sum by the count of positive numbers. Example 1 Input: ...
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 ...
Read MoreHow to Create Facebook Login Page in HTML and CSS
HTML stands for Hyper Text Markup language that is used to create the structure or layout of any webpage. CSS stands for cascading style sheets that are used to format and add styles to web pages. In this article, we are going to discuss how we can create a Facebook login page using HTML and CSS. Facebook Login Page A login page is the first page of any application or website. If we had already created our account on any website or app then we enter our login credentials on the login page to access our account. The ...
Read MoreC Program to Find if there is any subarray with a sum equal to 0
A subarray is a contiguous part of the array. The sum of elements in a subarray is the cumulative sum of elements of a subarray. For example: in the given array [1, 2, 3, 4, 5, 6] the subarray is [3, 4, 5]. In this article, we are given an array and need to find if any subarray has a sum equal to zero using C. Problem Statement Example 1 Input: arr[] = {4, 2, -3, 1} Output: Yes Explanation: The subarray {2, -3, 1} has a sum equal to 0. Example ...
Read MoreProgram to Rotate a matrix by 90 degrees in the clockwise direction in C
In this article, we are given an N x N matrix, and our task is to rotate it by 90 degrees clockwise in C. Syntax void rotateMatrix(int matrix[N][N]); // For brute force approach void rotateMatrixInPlace(int matrix[N][N]); // For in-place rotation approach Example Input: [1 2 3], [4 5 6], [7 8 9] Output: [7 4 1], [8 5 2], [9 6 3] Below are different approaches to rotate a matrix by 90 degrees in the clockwise direction − Using Brute Force Approach ...
Read MoreC Program to Find an Automorphic Number
In C, an automorphic number is a positive integer whose square ends with the number itself. For example, 52 = 25 (ends with 5), and 252 = 625 (ends with 25). This article demonstrates how to check whether a given number is automorphic in C programming. Syntax int isAutomorphicNumber(int num); Examples of Automorphic Numbers Consider the following examples to understand automorphic numbers − 5: 52 = 25 (ends with 5) − Automorphic 25: 252 = 625 (ends with 25) − Automorphic 7: 72 = 49 (ends with 49, not 7) − Not ...
Read MorePHP Program to Calculate the Average of an Array of Numbers
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 MorePHP Program to Find the Percentage of a Number
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 MorePHP Program to Calculate Simple Interest and Compound Interest
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 MoreHow to Add Two Numbers in PHP Program?
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