Found 33676 Articles for Programming

Maximum number of Zombie processes a system can handle in C++

Sunidhi Bansal
Updated on 17-Aug-2020 09:21:18

211 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

Sum of two numbers modulo M in C++

sudhir sharma
Updated on 17-Aug-2020 09:40:20

624 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

Maximum number of unique prime factors in C++

Sunidhi Bansal
Updated on 17-Aug-2020 09:20:03

1K+ 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

Maximum number of trailing zeros in the product of the subsets of size k in C++

Sunidhi Bansal
Updated on 17-Aug-2020 09:18:22

250 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

Maximum number of segments of lengths a, b and c in C++

Sunidhi Bansal
Updated on 17-Aug-2020 09:16:11

287 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

Maximum number of pieces in N cuts in C++

Sunidhi Bansal
Updated on 17-Aug-2020 09:14:19

775 Views

Given the task is to calculate the maximum number of square or rectangle pieces of equal size that can be obtained by cutting a given square piece in total N number of cuts horizontally or vertically.Let’s now understand what we have to do using an example −Input − N=8Output − 25Explanation − When N=8, the number of vertical cuts = 4 and the number of horizontal cuts = 4.Total pieces = 2512345678910111213141516171819202122232425Input − 7Output − 201234567891011121314151617181920Approach used in the below program as followsIf N is the number of cuts and we have to maximize the resultant pieces then equal number ... Read More

Maximum number of parallelograms that can be made using the given length of line segments in C++

Sunidhi Bansal
Updated on 17-Aug-2020 09:12:37

161 Views

Given the task is to find the maximum number of parallelograms that can be made using given N number of line segments if each line segment can be used at most in one parallelogram.Let’s now understand what we have to do using an example −Input − Arr[] = {8, 3, 1, 3, 8, 7, 1, 3, 5, 3}Output − 2Explanation − With the above given line segments, the two parallelograms that can be formed are with sides 8, 1, 8, 1 and 3, 3, 3, 3 respectively.Input − Arr[] = {7, 9, 9, 7}Output − 1Approach used in the below ... Read More

Maximum number of ones in a N*N matrix with given constraints in C++

Sunidhi Bansal
Updated on 17-Aug-2020 09:10:45

170 Views

Given the task is to find the maximum number of ones in a binary matrix possible with the following constraints.Two integers N and X are given where X

What are C++ features missing in Java?

AmitDiwan
Updated on 17-Aug-2020 09:20:06

1K+ Views

There are many features that can be seen in C++ but not in Java. A few of them have been listed below −No unsigned int option in JavaNo destructor in Java as well as ‘delete’ since garbage collector performs this operation for it.No friend classes or friend functions in Java.There are no pointers in Java.There is no typedef option in Java.Since Java is a purely object oriented language, there are no global variables or global functions.The concept of templates present in C++ can’t be found in Java.The ‘::’ scope resolution operator is not there, since there is no question of ... Read More

Maximum number of groups of size 3 containing two type of items in C++

Sunidhi Bansal
Updated on 17-Aug-2020 09:09:27

190 Views

Given the task is to calculate the maximum number of groups of size 3 that can be formed when N number of items of type A and M number of items of type B are given.Also, each group should have at least one item of each type, that is either A or B.Let’s now understand what we have to do using an example −Input − N=3, M=5Input − 2ExplanationGroup 1: 1 item of type A and 2 items of type B Group 2: 1 item of type A and 2 items of type B In total, 2 items of type ... Read More

Advertisements