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

147 Views
Suppose we have an array of restaurants where restaurants[i] have [idi, ratingi, vegan friendly, pricei, distancei]. We have to filter the restaurants using three filters.The vegan-friendly filter will be either true (meaning we should only include restaurants with vegan-friendly set to true) or false (meaning we can include any restaurant).The maxPrice filter and max distance filter which are the maximum value for price and distance of restaurants we should consider respectively.We have to find the array of restaurant IDs after filtering, ordered by rating from highest to lowest. For restaurants with the same rating, order them by id in decreasing ... Read More

358 Views
Suppose we have N x M matrix, we have to sort this diagonally in increasing order from top-left to the bottom right. So if the matrix is like −331122121112The output matrix will be −111112221233To solve this, we will follow these steps −Define a method called solve(), this will take si, sj and matrix matn := number of rows and m := number of columnsmake an array called tempi:= si and j := sj, and index := 0while i < n and j < minsert m[i, j] into temp, then increase i and j by 1sort temp arrayset index := 0, ... Read More

2K+ Views
In this article, our task is to break a palindromic string. We have to replace exactly one character with any lowercase English letter such that the string becomes a lexicographically smallest possible string that isn't a palindrome. Now after doing so, we have to find the final string. If there is no way to do so, then return the empty string. Example Here is an example of breaking the given palindrome string by replacing one letter and the output is a non-palindromic lexicographically smallest string: Input: abccba Output: aaccba In the above ... Read More

153 Views
Suppose we have a binary tree and an integer target, we have to delete all the leaf nodes with value target. We have to keep in mind that once we delete a leaf node with a value target if it's parent node becomes a leaf node and has the value target, it should also be deleted (we need to continue doing that until we can't). So if the tree is like below, and the target is 2, then the final tree will be like the last one −To solve this, we will follow these steps −Define a recursive method called ... Read More

232 Views
IIn this tutorial, we will be discussing a program to understand how to delete elements in the C++ STL list.For this, we will be using the pop_back() and pop_front() function to delete the element from last and the front respectively.Example Live Demo#include #include using namespace std; int main(){ listlist1={10,15,20,25,30,35}; cout

195 Views
In this tutorial, we will be discussing a program to understand how to initiate a multidimensional array in C/C++.While declaring a multidimensional array, the value of the leftmost dimension can be left empty, but all other dimensions must be provided.Example Live Demo#include int main(){ int a[][2] = {{1,2},{3,4}}; printf("%lu", sizeof(a)); getchar(); return 0; }Output16

124 Views
In this tutorial, we will be discussing a program to understand extended integral types in C/C++.The data types in C are very loosely defined. Their range values changes on the basis of the compiler being 32 or 64 bit. To specify the compiler range you want to use in your program we use intN_t.Example Live Demo#include using namespace std; int main(){ uint8_t i; //mentioning the bit to be 8 i = 0; cout

1K+ Views
In this tutorial, we will be discussing a program to understand File Handling through C++ classes. What's File Handling? File handling is an important concept in programming, which allows a program to read from and write to files. C++ has built-in classes and functions for file handling, which is done using file stream classes that are part of the library. The most common file stream classes in C++ are ofstream, ifstream, fstream. ofstream: This class is used for output file streams, where it allows the user to write data to files. ... Read More

6K+ Views
In this tutorial, we will be discussing a program to draw a line in C++ graphics.To implement different shapes and sizes, animations, graphics.h library is used in C++.Example#include int main(){ int gd = DETECT, gm; initgraph(&gd, &gm, ""); line(150, 150, 450, 150); line(150, 200, 450, 200); line(150, 250, 450, 250); getch(); closegraph(); return 0; }Output

203 Views
In this tutorial, we will be discussing a program to understand if the C++ compiler creates a default constructor when we write our own.Generally, the C++ compiler uses the default constructor when no one is defined, but always uses the one defined by the user if any.Example Live Demo#include using namespace std; class myInteger{ private: int value; //other functions in class }; int main(){ myInteger I1; getchar(); return 0; }OutputCompiles successfullyExample#include using namespace std; class myInteger{ private: int value; public: myInteger(int v) //user-defined constructor { value = ... Read More