- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 7347 Articles for C++
![sudhir sharma](https://www.tutorialspoint.com/assets/profiles/125719/profile/60_65058-1565947418.jpg)
336 Views
In this problem, we are given an array aar[] of n numbers. Our task is to create a program to find the Sum of XOR of all possible subsets.Here, we will find all subsets of the array. Then for each subset, we will find the XOR of elements of the subset and add them to the sum variable.Let’s take an example to understand the problem, Input: arr[] = {5, 1, 4} Output: 20 Explanation: XOR of all subsets: {5} = 5 {1} = 1 {4} = 4 {5, 1} = 4 {5, 4} = 1 {1, 4} = 5 {5, ... Read More
![sudhir sharma](https://www.tutorialspoint.com/assets/profiles/125719/profile/60_65058-1565947418.jpg)
2K+ Views
In this problem, we are given an array arr[] of n integers. Our task is to create a program to find the sum of XOR of all pairs in an array.Let’s take an example to understand the problem, Input: arr[] = {5, 1, 4} Output: 10 Explanation: the sum of all pairs: 5 ^ 1 = 4 1 ^ 4 = 5 5 ^ 4 = 1 sum = 4 + 5 + 1 = 10One simple approach to solve this problem is to run nested loops and find all pairs of numbers. Find XOR of each pair and add ... Read More
![sudhir sharma](https://www.tutorialspoint.com/assets/profiles/125719/profile/60_65058-1565947418.jpg)
871 Views
In this problem, we are given a matrix. Our task is to create a program to print the sum of upper triangle and lower triangle.Lower triangleM00 0 0 … 0 M10 M11 0 … 0 M20 M21 M22 … ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
88 Views
Given the task is to find the maximum number without any leading or trailing zeroes or ones whose product of factorial of its digits is equal to the product of factorial of digits of the given number N.Let’s now understand what we have to do using an example −Input − N = 4912Output − 73332222Explanation − 4! * 9! * 1! * 2! = 7! * 3! * 3! * 3! * 2! * 2! *2! *2! = 17, 418, 240Input − N = 340Output − 3322Approach used in the below program as followsIn order to attain the maximum answer ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
259 Views
Given the task is to find the maximum number that can be displayed using N segment on ant number of seven segment display.Let’s now understand what we have to do using an example −Input − N=5Output − 71Explanation − The largest number will be displayed as follows on the seven segment display −Input − N=6Output − 111Approach used in the below program as followsThe following situation can be divided into 3 case −Case 1 −If N is 0 or 1, then it is not possible to display any number.Case 2 −If N is odd. Then the numbers that can be ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
126 Views
Given the task is to find the maximum number of Zombie processes that a system can handle or in other words, the program does not stop its execution.A Zombie process (also known as defunct process) is a process that has completed its process via exit() (system call) but still has an entry in the process table.Approach used in the below program as followsNote that should be added in order to run the program.In main() function initialize num = 0 of type int which we will iterate until the program stops being executed.To initiate a zombie process create a while statement ... Read More
![sudhir sharma](https://www.tutorialspoint.com/assets/profiles/125719/profile/60_65058-1565947418.jpg)
488 Views
In this problem, we are given three numbers a, b, and M. our task is to create a program to find the sum of two numbers modulo M.Let’s take an example to understand the problem, Input: a = 14 , b = 54, m = 7 Output: 5 Explanation: 14 + 54 = 68, 68 % 7 = 5To solve this problem, we will simply add the numbers a and b. And then print the remainder of the sum when divided by M.ExampleProgram to illustrate the working of our solution, Live Demo#include using namespace std; int moduloSum(int a, int ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
985 Views
Given the task is to find the maximum number of unique prime factors a number can have in the range of [1, N] where N is given.Let’s now understand what we have to do using an example −Input − N=100Output − 3Explanation − Let us take 30 in the range of [1, 100]30 = 3 * 2 * 5 = unique prime factors. Therefore, in the range of [1, 100] a maximum of 3 unique factors can be found.Input − N=300Output − 4Approach used in the below program as followsIn function MaxPrime() we will first check if (N < 2). ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
159 Views
Given the task is to find the maximum number of trailing zeroes in the product of the subsets of size K, of a given array of size N.Let’s now understand what we have to do using an example −Input − Arr[] = {5, 20, 2} , K=2Output − 2Explanation − A total of 3 subsets can be created having size = 2.The product of [5, 20] is 100.The product of [20, 2] is 40.The product of [5, 2] is 10.100 has the maximum number of trailing zeros = 2. Therefore 2 is the answer.Input − Arr[] = {60, 40, 25} ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
189 Views
Given the task is to find the maximum number of line segments of lengths a, b and c that can be formed from given positive integer N.Let’s now understand what we have to do using an example −Input − N=8, a=3, b=1, c=2Output − 8Explanation − N can be divided into 8 segments of b which is maximum number of segments that can be made.Input − N=13, a=2, b=7, c=3Output − 6Approach used in the below program as followsIn function MaxSegment() declare an array MaxSeg[N +1] of type int and initialize it with value -1.The put the zero-th index equal ... Read More