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

228 Views
In this problem, we are given an array arr[] of n elements that represent N index positions and there are C magnets. Our task is to print all these magnets in such a way that the distance between the two nearest magnets is as large as possible.Let’s take an example to understand the problem, Input − array = { 1, 4, 6, 12, 28, 44 } C = 4Output − 11To solve this problem, we will use a binary search to maximum distance. We will fix a maximum distance and then placing all magnets between 0 to maximum distance is ... Read More

157 Views
In this problem, we are given a number n. Our task is to print all Pierpont prime numbers less than n.Pierpont Prime number is a special type of prime number that is of the form, p= 2i . 3k + 1.Where p is a prime number, and i and k are some integers.Let’s take an example to understand the problem, Input − n = 50Output − 2, 3, 5, 7, 13, 17, 19, 37To solve this problem, we have to find all the prime numbers that follow the condition. For this, we will find a number with factors of powers ... Read More

203 Views
Pipes and cisterns problem is a very common problem and is generally included in competitive exams. So, learning questions related to pipers and cisterns is important and you should know how to solve them as these are not too difficult to learn.Pipes and cisternsThese problems involve pipes that are used to either fill or empty a tank/reservoir/cistern.Here, are some basics of pipes and cisterns problem, The pipes are inlet pipes or outlet pipes. Inlet pipe fills the tank and the outlet pipe empties the tank.If a pipe fills/empties in ‘n’ hours and the capacity of the tank is ‘c’ liters. ... Read More

1K+ Views
In this problem, we are given an array of n points that lie on the same line. Our task is to place k elements of the array in such a way that the minimum distance between them is maximized.Let’s take an example to understand the problem, Input − array = {}Output −To solve this problem, we will find have to find the maximum possible minimum distance. For such a problem first, we need to sort the given array and then do a binary search until we get the solution at mid.ExampleProgram to show the implementation of our solution, Live Demo#include ... Read More

578 Views
In this problem, we are given three integer value K, N, M. our task is to place K knights in an NxM chessboard such that no two knights attack each other. There can be cases with 0 valid ways and also cases with multiple valid ways. You need to print all valid cases.Knight is a chess piece that moves two moves ahead and then one move to the left of right. It can move in any direction in the chessboard.Attack is the position when one piece can be in the same place as other pieces in one chance of its ... Read More

187 Views
In this problem, we are given an integer value N. our task is to print numbers within the range (1, N2) in a 2D matrix of size NxN in such a way that the sum elements of each row are equal.Let’s take an example to understand the problem, Input − N = 4Output −1 6 11 16 2 7 12 13 3 8 9 14 4 5 10 15Sum of elements in each row is 34To solve this method, we need to place each element in the matrix in such a way that the total in each row is equal. ... Read More

976 Views
Destructor is a function of a class in c++ that does the job of deleting the object of a class.Calling a destructorDestructor is called when the object of a class goes out of the scope in the program. The cases when object goes out of scope, The program goes out of the scope of a function.The program ends.The block initializing local variables of object goes out of scope.When the operator of the object is deleted.ExampleLet’s see a code and guess the output of the program, Live Demo#include using namespace std; int i; class destructor { public: ... Read More

2K+ Views
In this article we will be discussing how we can quickly merge two sorted arrays using std::merge() function in C++ STL.So, before solving the problem let's first discuss the std::merge() in C++ STL.What is std::merge()?std::merge() function is an inbuilt function in C++ STL, which is defined in the header file. merge() is used to merge two sorted ranges or series. This function combines two sorted ranges to make one single sorted range. All the elements are compared using less than operator (

238 Views
In this article we will be discussing the working, syntax and examples of quick_exit() function in C++ STL.What is quick_exit()?quick_exit() function is an inbuilt function in C++ STL, which is defined in the header file. quick_exit() function is used to quickly terminate the calling process means it terminates the process without cleaning of its resources.This function is used for normal termination and no additional cleanup tasks are being performed like, no object destructors are called, whereas the C streams are closed or flushed, the files which are opened with tmpfile are being removed.When we terminate a process using quick_exit() ... Read More

114 Views
In this article we will be discussing the working, syntax and examples of putwchar() function in C++ STL.What is putwchar()?putwchar() function is an inbuilt function in C++ STL, which is defined in the header file. putwchar() function is used to write the wide character on the standard output device. This function takes the wide character from the arguments and writes it on the stdout or standard output of the system.This function is a wide character version of putchar() which is defined in the header file.Syntaxputwchar( wchar_t widec );ParametersThe function accepts following parameter(s) −widec − The wide character which ... Read More