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 5 of 12
Python Program to Find Average of Array Elements
In this article, we will learn how to find the average of array elements using Python, along with examples to demonstrate the implementation. In this problem, we are given an array of integers, which may contain both positive and negative numbers. Our task is to calculate the average of all elements in the array. Using the Brute Force Approach This is a simple and direct approach. This approach involves manually iterating through each element in the array to calculate the sum. Then, we divide the total sum by the count of elements to get the average. This approach is ...
Read MorePython Program to Toggle Each Character in a String
In this problem, we are given a string, and the task is to toggle the case of each character in the string. This means that all lowercase letters should be converted to uppercase, and all uppercase letters should be converted to lowercase. In this article, we are going to explore different approaches to toggling each character in a string using Python. Let's look at the simple example, where we are going to provide input as "TutorialsPoint". Then output is like "tUTORIALSpOINT" In this case each character is toggled. Such that Uppercase letters become lowercase and lowercase becomes uppercase. Below are ...
Read MorePython Program for sum of the series: 1 + 1/2 + 1/3 + ... + 1/n
Mathematical series is one of the problems that helps us to improve problem-solving and logical thinking skills One of the engaging problems is calculating the sum of the harmonic series. The series 1 + 1/2 + 1/3 + ⋯⋯ + 1/n is known as the harmonic series. In this article, we are going to learn how to find the sum of the series: 1 + 1/2 + 1/3 + ⋯⋯ + 1/n using Python. What is the Harmonic Series? The harmonic series is a mathematical sequence where each term is the reciprocal of a positive integer. It is represented as, ...
Read MorePython Program to Implement Ternary Search
Searching is one of the most fundamental operations in computer science, and there are multiple algorithms to perform it efficiently. While Binary Search is mainly known to be applied to sorted array searching, Ternary Search is another efficient searching technique that also works on sorted arrays for searching. What is a Ternary Search Ternary Search is a divide-and-conquer algorithm that splits the array into three parts instead of two (as in Binary Search). It repeatedly reduces the search space by two-thirds in each step, making it useful in cases where the dataset is large, and constant-time comparisons are expensive. ...
Read MoreJava Program to Find the Volume of Cylinder
A cylinder is a three-dimensional geometric shape with two parallel circular bases connected by a curved surface. The volume of a cylinder can be calculated using a mathematical formula that considers its radius and height. Problem Description In this tutorial, we are going to discuss how to find the volume of a given cylinder in Java using different approaches. Formula for Volume of Cylinder The formula for the volume of a cylinder is as follows: Volume of Cylinder = π × r² × h where: r: The radius of the circular base. h: The height of the cylindrical body. ...
Read MoreC# Program to Find Volume, Perimeter and Surface Area of Cuboid
What is a Cuboid? A cuboid is a three-dimensional figure with six rectangular faces, where opposite faces are equal in dimensions. We can calculate the volume, perimeter, and surface area of a cuboid using specific formulas based on its length, breadth, and height. Problem Statement Given length, breadth, and height. You need to find its volume, perimeter, and surface area using different approaches in C#. Formulas for Cuboid Calculations The following are the formulas for the volume, perimeter, and surface area of a cuboid: The Volume of a Cuboid: Volume = length × breadth × height The ...
Read MorePHP Program to Print Multiplication Table
A multiplication table is a useful mathematical tool that is used to print the products of a given number with a range of values, generally, it is printed from 1 to 10. In this article, we are going to learn multiple ways to generate and print multiplication tables in PHP. Formula to Generate Multiplication Table To create a multiplication table for any number, use the formula: Answer = Number × MultiplierWhere:number is the fixed value for which the table is generated.Multiplier is the range of values (e.g., 1 to 10). Example 1 Input: Number ...
Read MorePython Program to Find Cube of a Number
The Cube of a number is a simple mathematical operation where a number is multiplied by itself three times. In Python, there are multiple ways to find the cube of a number. In this article, we are going to discuss various approaches to calculating the cube of a number in Python. How to find cube of a number? The formula for finding the cube of a given number N is: Cube = N × N × N or N3 Example 1 Input: 5 Output: 125 Explanation: The cube of ...
Read MoreC++ Program for Absolute Sum of Array Elements
In this problem, we are given an array of integers, and our task is to calculate the absolute sum of its elements. The absolute sum means the sum of the absolute values of all the array elements. In this article, we are going to learn how to compute the absolute sum of an array's elements using C++. Example 1 Input: arr = {-3, 2, -7, 4} Output: 16 Explanation: The absolute values of the array elements are: | -3 | = 3, | 2 | = 2, | -7 | = 7, | 4 | = 4. The sum of ...
Read MoreC# Program to Find the Sum of First N Natural Numbers
We are given a number N, and we need to calculate the sum of the first N natural numbers. In this article, we are going to learn how we can find the sum of the first N natural numbers in C#. Example 1 Input: N = 3 Output: 6 Explanation − The first 3 natural numbers are: 1, 2, 3 The sum of these numbers is: 1 + 2 + 3 = 6 Example 2 Input: N = 5 Output: 15 Explanation − The first 5 natural numbers are: 1, 2, 3, 4, 5 ...
Read More