Ravi Ranjan has Published 148 Articles

Arithmetic Mean in c++?

Ravi Ranjan

Ravi Ranjan

Updated on 25-Jul-2025 17:07:37

2K+ Views

An arithmetic mean is the average of all the given numbers, which is calculated by summing all the numbers and dividing this calculated sum by the total number of elements. The formula for calculating the arithmetic mean is: $$ \bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i = ... Read More

Array algorithms in C++ STL

Ravi Ranjan

Ravi Ranjan

Updated on 24-Jul-2025 18:35:20

685 Views

The C++ STL or Standard Template Library is a collection of general-purpose classes and functions with templates for implementing many algorithms and data structures such as vectors, lists, queues, and stacks. The 4 components of STL are: Containers, Algorithms, Iterators, and Functors. In this article, we will discuss ... Read More

Arranging Coins in C++

Ravi Ranjan

Ravi Ranjan

Updated on 24-Jul-2025 18:33:45

368 Views

In this problem, we have n number of coins. To arrange these coins in a staircase shape such that each row consists of k number of coins, where k is the row number in which the coins are placed. The last row may or may ... Read More

Accessing array out of bounds in C/C++

Ravi Ranjan

Ravi Ranjan

Updated on 23-Jul-2025 18:57:52

2K+ Views

An array in C/C++ is a fixed-size sequential collection of elements of the same data type where all the elements are stored in the contiguous memory allocation. If an array is accessed out of bounds then an undefined behavior will occur in C/C++, unlike Java ... Read More

Maximum triplet sum in array in C++

Ravi Ranjan

Ravi Ranjan

Updated on 23-Jul-2025 18:52:56

318 Views

In this article, we are given an array of integers. Our task is to write a program to calculate the maximum triplet sum in the given array, i.e., find the set of three elements whose sum is maximum. Input Output Scenario Consider the ... Read More

Activity Selection Problem

Ravi Ranjan

Ravi Ranjan

Updated on 21-Jul-2025 19:07:32

6K+ Views

Activity Selection Problem The activity selection problem is an example of a greedy algorithm where the maximum number of non-overlapping activities are selected from the given activity set. A person can complete one activity at a time. The activities are given in the form of their ... Read More

Sum of the series 1 + (1+2) + (1+2+3) + (1+2+3+4) + ... + (1+2+3+4+...+n) in C++

Ravi Ranjan

Ravi Ranjan

Updated on 16-Jul-2025 18:15:22

842 Views

In this article, we are given a number n. Our task is to write a program to calculate the sum of the series 1 + (1+2) + (1+2+3) + (1+2+3+4) + … + (1+2+3+4+...+n). This series can be represented mathematically as: $$ \displaystyle\sum\limits_{k=1}^n \displaystyle\sum\limits_{j=1}^k j ... Read More

Sum of the series 1 / 1 + (1 + 2) / (1 * 2) + (1 + 2 + 3) / (1 * 2 * 3) + … + upto n terms in C++

Ravi Ranjan

Ravi Ranjan

Updated on 15-Jul-2025 18:29:51

1K+ Views

In this article, we are given an integer n. It defines the number of terms in the series: 1/1 + ( (1+2)/(1*2) ) + ( (1+2+3)/(1*2*3) ) + … + up to n terms. Our task is to write a program to calculate the sum ... Read More

Angle Between Hands of a Clock in C++

Ravi Ranjan

Ravi Ranjan

Updated on 15-Jul-2025 18:27:16

2K+ Views

In this article, we have values of hours and minutes respectively. Our task is to find a smaller angle formed between the hour and the minute hand. The formula for calculating the angle between them is: angle = |30*h - 5.5min|. Here are some examples given below: ... Read More

_Noreturn function specifier in C

Ravi Ranjan

Ravi Ranjan

Updated on 11-Jul-2025 18:16:55

224 Views

The _Noreturn function specifier in C indicates to the compiler that the function will either exit or run in an infinite loop. This function never returns the control to the main function or wherever it was called in the program. If the _Noreturn function uses ... Read More

Advertisements