C++ Articles

Page 145 of 597

Count elements that are divisible by at-least one element in another array in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 450 Views

We are given two arrays, let's say arr_1[] and arr_2[] both containing integer values and the task is to calculate the count of elements that are divisible by at least one element in another array. It means there we need to count those elements having at least one factor in the second array which is arr_2.Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables ...

Read More

Program to find N-th term of series 9, 23, 45, 75, 113... in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 321 Views

In this problem, we are given an integer n that denotes the nth term of the series. Our task is to create a program to find N-th term of series 9, 23, 45, 75, 113… in C++.Problem Description − Here, we need to find the nth term of the series for which we will be finding the general term of the series.The series is 9, 23, 45, 75, 113, 159, 213, …Let’s take an example to understand the problem, Input − n = 5output − 159Solution Approach, The general term of the given series isNth term = ( ((2*N + ...

Read More

Count number of distinct pairs whose sum exists in the given array in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 638 Views

We are given an array of, let's say, arr[] of integer values of any respective size and the task is to calculate the count of the number of distinct pairs available in a given array whose sum also exists in the same array.Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.Points to rememberA pair will be counted once with the ...

Read More

Count distinct pairs from two arrays having same sum of digits in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 301 Views

We are given with two arrays let’s say, arr_1[] and arr_2[] having integer values and the task is to calculate the count of distinct pairs having the same sum of digits. It means, one value should be selected from an arr_1[] and second value from arr_2[] to form a pair and both the values should have the same sum digits.Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as ...

Read More

Count array elements that divide the sum of all other elements in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 383 Views

We are given an array let’s say, arr[] of integer values and the task is to calculate the count of array elements that divides the sum of all other elements.Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.For ExampleInput − int arr_1[] = {9, 6, 3} Output − count is 3Explanation − As the sum of elements 9+6 = 15 ...

Read More

Program to find out the data type of user input in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 1K+ Views

In this problem, we are given input from the user. Our task is to create a program to find out the data type of user input in C++.Problem Description − We will take input from the user and check the data type of the input value.Let’s take an example to understand the problem, Example 1:Input − 34Output − It is an integerExample 2:Input − tutorialspointOutput − It is a stringSolution Approach:We will check if the input string is a number or not a number.If it is a number, we will check if it is an integer or a float value.If ...

Read More

Count divisors of array multiplication in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 369 Views

We are given an array let’s say, arr[] of integer elements of any given size and the task is to calculate the count of the factors of a number calculated by multiplying all the array elements.Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.For exampleInput − int arr[] = {2, 3} Output − count is 4Explanation − the multiplication of ...

Read More

Count maximum elements of an array whose absolute difference does not exceed K in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 641 Views

We are given an array let’s say, arr[] of integer elements of any given size and a positive integer k and the task is to calculate the count of those element pairs whose absolute difference doesn’t exceed the given integer k.Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.For exampleInput − int arr[] = {2, 3, 6, 12, 14}, k= ...

Read More

Program to find Prime Numbers Between given Interval in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 382 Views

In this tutorial, we will be discussing a program to find prime numbers between given intervals.For this we would be provided with two integers. Our task is to find the prime numbers in that particular range.Example#include using namespace std; int main() {    int a, b, i, j, flag;    //getting lower range    a = 3;    //getting upper range    b = 12;    cout

Read More

Count BST nodes that lie in a given range in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 365 Views

We are given a binary search tree made up of nodes and also a range and the task is to calculate the count of nodes that lies in the given range and display the result.A Binary Search Tree (BST) is a tree in which all the nodes follow the below-mentioned properties −The left subtree of a node has a key less than or equal to its parent node's key.The right subtree of a node has a key greater than to its parent node's key.Thus, BST divides all its sub-trees into two segments; the left subtree and the right subtree and ...

Read More
Showing 1441–1450 of 5,962 articles
« Prev 1 143 144 145 146 147 597 Next »
Advertisements