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

2K+ Views
Here we will see what are the type conversion techniques present in C++. There are mainly two types of type conversion. The implicit and explicit.Implicit type conversionThis is also known as automatic type conversion. This is done by the compiler without any external trigger from the user. This is done when one expression has more than one datatype is present.All datatypes are upgraded to the datatype of the large variable.bool -> char -> short int -> int -> unsigned int -> long -> unsigned -> long long -> float -> double -> long doubleIn the implicit conversion, it may lose ... Read More

211 Views
Here we will see some good reasons behind taking the language C++ as our favorite programming language. We know that C++ is one of the most popular object oriented programming language. These are the reasons behind taking the C++ into consideration.C++ Popularity and High salary −C++ is one of the most popular language in the world. It is used nearly 4.4 million developers worldwide. The C++ developers hold highest paying jobs in the industry with an average base pay of $100000 per year.C++ has abundant library supportv −C++ has Standard Template Library (STL). This helps to write code compactly and ... Read More

933 Views
Here we will see how to design timer in C++ using a system call. We will not use any graphics or animations. Here timer means the stopwatch, that is up-counting the time. The used system calls are −sleep(n) − This will help the program to sleep for n number of secondssystem() − This is used to execute the system command by passing command as an argument to this function.Example Live Demo#include #include #include #include using namespace std; int hrs = 0; int mins = 0; int sec = 0; void showClk() { system("cls"); cout

917 Views
Suppose we have an array of dates. Here we will see how to sort then using C or C++ code. The dates are stored in a class (struct can be used in C also). We will use the sort function of the C++ STL. For comparing dates, we have to write our own compare function that will be used in the sort function. Let us see the example to get better view.Example Live Demo#include #include #include using namespace std; class Date { public: int d, m, y; }; bool compare(const Date &date1, const Date &date2){ if ... Read More

143 Views
Suppose we have a string. We have to find the balancing position count in that string from where left and right part of the string contains same characters. The frequency of characters does not matter. So if the string is “ABAABA”, then the number of balancing positions is 3. These positions are AB|AABA, ABA|ABA, ABAA|BA.To solve this, we will follow some efficient approach. After traversing the string we first feel right[] with counts of all characters. Then traverse the string from left to right. For every character we increment its count in left[] and decrement the count in right. For ... Read More

272 Views
Suppose we have two arrays X and Y of positive integers. Find the number of pairs such that x^y > y^x, where x is an element of X and y is an element of Y. Suppose the X = [2, 1, 6], and Y = [1, 5], then output will be 3. As there are three pairs, these are (2, 1), (2, 5) and (6, 1)We can solve this in an efficient way. The logic is simple, it will be when y > x then x^y > y^x with some exceptions. So this is the trick.Sort the array Yfor each ... Read More

228 Views
Suppose we have three stacks of positive numbers. We have to find the possible equal maximum sum of stacks with removal of top elements allowed. The stacks are represented as an array. The first index of the array represents the top element of the stack. Suppose the stack elements are like [3, 10], [4, 5] and [2, 1]. The output will be 0. The sum can only be equal after removing all elements from all stacks.To solve this, we will follow this idea. The idea is to compare the sum of each stack, if they are not equal, then remove ... Read More

739 Views
Suppose we have an array of n objects. Each object has width W[i]. We have to arrange them in a pyramidal way like −Total width of ith is less than (i + 1)thTotal number of objects in the ith is less than (i + 1)thFor example, if the weights are like [40, 100, 20, 30], then output will be 2. So top level is 30, then lower level 20, 40 and 100To solve this, we will use the greedy approach. The idea is to use place the objects with lower width at the top, the next object at the level ... Read More

368 Views
Suppose we have two arrays of positive integers of size m and n. The m > n. We have to maximize the dot product by inserting zeros in the second array. One thing we have to keep in mind that we will not change the ordering of the elements in the given arrays. Suppose the arrays are A = [2, 3, 1, 7, 8], and another array B = [3, 6, 7]. The output will be 107. We can maximize the dot product after inserting 0s at first and third position of the second array. So the product will be ... Read More