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 7 of 12
JavaScript program to find the average of all negative numbers in an array
In this problem, we are given an array of integers, which may contain both negative and positive numbers. We have to find the average of all the negative numbers in the array. In this article, we are going to learn how we can find the average of all negative numbers in an array using JavaScript. Example 1 Input arr = [1, -3, 4, -2, -5]; Output -3.33 Explanation The negative numbers in the array are -3, -2, and -5. Their sum is -10, and the number of negative elements is 3. The average is: -10 / 3 = -3.33. ...
Read MorePython Program for Fahrenheit to Celsius conversion
Problem Description In this problem, we are given a temperature value in Fahrenheit and we have to convert it to Celsius. This conversion is used in various real-world applications such as weather applications, scientific calculations, and data analysis. In this article, we are going to discuss, how we can convert Fahrenheit temperature to Celsius temperature in Python. Formula to Convert Fahrenheit to Celsius The formula for converting Fahrenheit to Celsius is: Celsius = (Fahrenheit - 32) / 1.8 Example 1 Input: Fahrenheit = 98.6 Output: Celsius = 37°C Explanation: The ...
Read MoreRemove Duplicates from an Unsorted Array in C++
Problem Description In this problem, we are given an unsorted array, and the task is to remove all duplicate elements from the array. The resulting array should only contain unique elements. In this article, we are going to explore different approaches to removing duplicates from an unsorted array in C++. Example 1 Input: array = {4, 3, 2, 4, 1, 3, 2} Output: {4, 3, 2, 1} Explanation: The duplicate elements (4, 3, 2) are removed, leaving only unique elements. Example 2 Input: array ...
Read MoreC++ program to calculate potential energy if mass and height are given
What is Potential Energy? Potential energy is a type of stored energy stored by an object due to its position relative to other objects. It is an important concept in physics and is commonly calculated when studying objects in gravitational fields. In this tutorial, we are going to learn how to calculate the potential energy of an object in C++ if the mass and height are given. Formula for Calculating Potential Energy The formula for potential energy is as follows: Potential Energy = m × g × h Where:m is the mass of the object (in kilograms).g is the gravitational ...
Read MoreFinding sum of alternative elements of the array using C++
The sum of alternate elements has various real-life applications such as signal processing, data compression, pattern recognition, gaming, and financial data analysis. Problem Description In this article, we are going to learn how to find the sum of alternate elements of an array in C++. Alternate elements are present at even or odd indices of the array, depending on how we define them. Example 1 Inputarray = [1, 2, 3, 4, 5] OutputSum_even = 9Sum_odd = 6 Explanation The alternate elements at the even index are 1, 3, 5 (at ...
Read MorePython program to find perimeter of rectangle
A rectangle is a closed two-dimensional figure having 4 sides. The opposite sides are equal and parallel. The angle made by the adjacent side is equal to 90 degrees. The perimeter is the sum of all sides; in other words, the perimeter is two times the sum of length and breadth. In this tutorial, we are going to learn how we can find the perimeter of a given rectangle in Python using different approaches. Formula of Perimeter of Rectangle The formula for the perimeter of a rectangle is as follows: Perimeter of Rectangle = 2 × (length + breadth) ...
Read MorePython program to find volume of capsule
What is Capsule and Its Volume? A capsule is a three-dimensional geometric figure that consists of a cylindrical body with hemispherical ends on both sides. The volume of a capsule can be calculated by adding the volume of the cylindrical part and the volume of the two hemispherical ends present on both sides of the cylindrical part. In this tutorial, we are going to discuss how to find the volume of a given capsule in Python using different approaches. Formula for Volume of Capsule The formula for the volume of a capsule is as follows: Volume of Capsule = ...
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 Example 1 Input: string = "Tutoriaspoint" ...
Read MorePython program to find perimeter of square
A square is a closed two-dimensional figure having 4 equal sides. Each angle of a square is 90 degrees. The perimeter of a square is the sum of all its sides. Problem Description In this problem, we are given the side of a square, and we have to find the perimeter of the square. In this tutorial, we are going to find the perimeter of a given square in Python using different approaches. Example 1 Input: side = 6 units Output: 24 units Explanation Using the formula to calculate ...
Read MoreC# Program to Subtract Two Numbers
Problem Description In this problem, we are given two numbers, and we have to find the value obtained after subtracting one number from another. In this article, we are going to learn how we can subtract two numbers in C# using different approaches. Example 1 Input:number1 = 8number2 = 12 Output: 4 Explanation The subtraction of number2 - number1, i.e., 12 - 8, will result in 4. Example 2 Input:number1 = 10number2 = 10 Output: 0 ...
Read More