Programming Articles - Page 1955 of 3366

Count divisors of array multiplication in C++

Sunidhi Bansal
Updated on 15-May-2020 12:02:31

319 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 array elements that divide the sum of all other elements in C++

Sunidhi Bansal
Updated on 15-May-2020 12:00:37

330 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

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

Sunidhi Bansal
Updated on 15-May-2020 11:57:58

257 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 number of distinct pairs whose sum exists in the given array in C++

Sunidhi Bansal
Updated on 15-May-2020 11:53:57

570 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 elements that are divisible by at-least one element in another array in C++

Sunidhi Bansal
Updated on 15-May-2020 11:51:29

391 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

Count divisible pairs in an array in C++

Sunidhi Bansal
Updated on 15-May-2020 11:46:43

282 Views

We are given an array of any size containing integer elements and the task is to calculate the count of pairs in an array such that one element of a pair divides another element of a pair.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, 2, 3, 6} Output − count is 4Explanation − ... Read More

Count number of elements between two given elements in array in C++

Sunidhi Bansal
Updated on 15-May-2020 10:42:22

1K+ Views

We are given an array containing integer elements and two numbers start and end and the task is to calculate the count of elements present between start and end in an 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. If the start element is occurring multiple times then we will consider the first occurrence of the start element and ... Read More

Count elements present in first array but not in second in C++

Sunidhi Bansal
Updated on 15-May-2020 10:40:00

141 Views

We are given an array of any size containing integer elements and the task is to calculate the count of elements that are present in the first array but not in the second 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.For exampleInput− int arr_1[] = {1, 2, 3, 4}       Int arr_2[] = {1, 5, 6, 7, ... Read More

Count distinct elements in an array in C++

Ravi Ranjan
Updated on 11-Jun-2025 18:42:43

8K+ Views

In this article, we have an unsorted array of integers having repetitive elements. Our task is to count the distinct elements in the given array in C++. Example Here is an example of counting the unique number in the given array: Input: array = {4, 2, 32, 26, 57, 52, 40, 2, 57, 40, 33} Output: Distinct elements in the array: 8 Here is a list of approaches for counting distinct elements in the given array: Using Nested for Loop Using Sorting ... Read More

Count and Print the alphabets having ASCII value not in the range [l, r] in C++

Sunidhi Bansal
Updated on 15-May-2020 10:35:11

168 Views

We are given with a string of any length and the task is to calculate the count and print the alphabets in a string having ASCII value not in the range [l, r]ASCII value for character A-Z are given belowABCDEFGHIJKLMNOPQRS65666768697071727374757677787980818283TUVWXYZ84858687888990ASCII value for characters a-z are given belowabcdefghijklmnopqrs979899100101102103104105106107108109110111112113114115tuvwxyz116117118119120121122For ExampleInput − String str = “point       First = 111, Last = 117 Output − characters not in the given range are: i, n       Count is: 2Explanation − since i and n don't lies in the range of [111, 117] these characters will be counted.Input − String str ... Read More

Advertisements