
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

279 Views
We are given a sorted array of integer type elements and an integer variable x and the task is to form the pairs from the given array and calculate the product of elements in the pair and check whether the calculated product is less than k or not.Input int arr[] = {2, 7, 1, 0, 8}, int k = 10Output Count of pairs in a sorted array whose product is less than k are: 7Explanation The pairs that can be formed from the given array are: (2, 7) = 14(greater than k), (2, 1) = 2(less than k), (2, 0) = 0(less than ... Read More

650 Views
We are given a sorted array of integer type elements and an integer variable x and the task is to form the pairs from the given array and calculate the sum of elements in the pair and check whether the calculated sum is less than x or not.Input − int arr[] = {2, 7, 1, 0, 8}, int x = 8Output − Count of pairs in a sorted array whose sum is less than x are − 4Explanation − The pairs that can be formed from the given array are: (2, 7) = 9(greater than x), (2, 1) = 3(less ... Read More

290 Views
We are given an array of integer type elements and the task is to form the pairs from the given array and calculate the set bits of elements in the pair and check whether both the elements are having equal number of set bits or not.Set bits in a binary number is represented by 1. Whenever we calculate the binary number of an integer value then it is formed as the combination of 0’s and 1’s. So, the digit 1 is known as set bit in the terms of the computer.Input int arr[] = {6, 5, 1, 3, 7}Output Count of pairs ... Read More

2K+ Views
We are given an array of integer type elements and the task is to form the pairs from the given array and calculate the sum of elements in the pair and check whether the given sum is divisible by k or not.Input − int arr[] = {4, 1, 2, 0, 2}, int k = 2Output − Count pairs in array whose sum is divisible by k are − 2Explanation − The pairs that can be formed from the given array are: (4, 1) = 5(not divisible by 2), (4, 2) = 6(divisible by 2), (4, 0) = 4(divisible by 2), ... Read More

314 Views
We are given an array of integer type elements and the task is to form the pairs from the given array and calculate the sum of elements in the pair and check whether the given sum is divisible by 4 or not.Input − int arr[] = {4, 1, 2, 0, 2}Output − Count pairs in array whose sum is divisible by 4 are − 2Explanation − The pairs that can be formed from the given array are: (4, 1) = 5(not divisible by 4), (4, 2) = 6(not divisible by 4), (4, 0) = 4(divisible by 4), (1, 2) = ... Read More

333 Views
We are given two arrays of integer type elements let’s say, arr_1[] and arr_2[] and the task is to pick one element from arr_1[] and another element from arr_[] to form a pair then calculate the sum of elements in the pair and check whether the resultant sum is even or not.Input int arr_1[] = {2, 3, 7, 1, 4} int arr_2[] = { 2, 4, 1, 3}Output Count Pairs from two arrays with even sum are: 10Explanation We will form the pairs using both the arrays and the pairs so formed are-: (2, 2) = 4(valid), (2, 4) = 6(valid), (2, 1) ... Read More

230 Views
We are given an array of integer type elements and the task is to form the pairs from the given array and calculate the product of elements in the pair and check whether the given product is present in the given array or not.Input − int arr[] = {6, 2, 3, 1, 5, 10}Output − Count of pairs whose products exist in same array are − 7Explanation − The pairs that can be formed from the given array are: (6, 2), (6, 3), (6, 1), (6, 5), (6, 10), (2, 3), (2, 1), (2, 5), (2, 10), (3, 1), (3, ... Read More

427 Views
We are given a number let’s say, num and the task is to calculate the count of numbers in the range 1 to num that are divisible by 2, 3, 4, 5, 6, 7, 8, 9 and 10.Input − int num = 10000Output − Count numbers which are divisible by all the numbers from 2 to 10 are: 3Explanation − There are 3 numbers from 1 to 10000 that are divisible by all the numbers starting from 2 till 10 and those are −2520-: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 18, 20, 21, ... Read More

789 Views
We are given an integer number let’s say, num and the task is to firstly calculate the binary digit of a number and then calculate the total unset bits of a number.Unset bits in a binary number is represented by 0. Whenever we calculate the binary number of an integer value then it is formed as the combination of 0’s and 1’s. So, the digit 0 is known as unset bit in the terms of the computer.Input − int number = 50Output − Count of total unset bits in a number are − 3Explanation − Binary representation of a number ... Read More

273 Views
We are given an integer number let’s say, num and the range with left and right values. The task is to firstly calculate the binary digit of a number and then set the loop from the left digit till the right digit and then in the given range calculate the unset bits.Unset bits in a binary number is represented by 0. Whenever we calculate the binary number of an integer value then it is formed as the combination of 0’s and 1’s. So, the digit 0 is known as unset bit in the terms of the computer.Input − int number ... Read More