- 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 7401 Articles for C++
480 Views
Null pointer is a pointer which points nothing.Some uses of null pointer are:b) To initialize a pointer variable when that pointer variable isn’t assigned any valid memory address yet.b) To pass a null pointer to a function argument when we don’t want to pass any valid memory address.c) To check for null pointer before accessing any pointer variable. So that, we can perform error handling in pointer related code e.g. dereference pointer variable only if it’s not NULL.In C++ if we assign 0 in any pointer that means the pointer pointing to the NULL.SyntaxFloat *p = 0 //initializing the pointer ... Read More
497 Views
If a binary tree is traversed in-order, the left subtree is visited first, then the root and later the right sub-tree. The output the key in ascending order in in_order traversal. This is a C++ Program for Inorder Tree Traversal without Recursion.AlgorithmBegin Function inOrder(): Declare a stack s. Declare the current node as root. While current node is not null and stack is not empty do While current node is not null do Push the current node on the ... Read More
386 Views
Different operations on array and pseudocodes:Begin In main(), While TRUE do Prints some choices. Take input of choice. Start the switch case When case is 1 Print the size of the array. Break When case is 2 Insert the values in array. Break When case is 3 Print ... Read More
4K+ Views
vector::begin() function is a bidirectional iterator used to return an iterator pointing to the first element of the container.vector::end() function is a bidirectional iterator used to return an iterator pointing to the last element of the container.AlgorithmBegin Initialize the vector v. Declare the vector v1 and iterator it to the vector. Insert the elements of the vector. Print the elements. End.Example Code Live Demo#include #include using namespace std; int main() { vector v = { 50, 60, 70, 80, 90}, v1; //declaring v(with values), v1 as vector. vector::iterator it; //declaring an ierator ... Read More
619 Views
vector insert() function in C++ STL helps to increase the size of a container by inserting the new elements before the elements at the specified position.It is a predefined function in C++ STL.We can insert values with three types of syntaxes1. Insert values by mentioning only the position and value:vector_name.insert(pos, value);2. Insert values by mentioning the position, value and the size:vector_name.insert(pos, size, value);3. Insert values in another empty vector form a filled vector by mentioning the position, where the values are to be inserted and iterators of filled vector:empty_eector_name.insert(pos, iterator1, iterator2);AlgorithmBegin Declare a vector v with values. Declare ... Read More
96 Views
unordered_multimap swap() function in C++ STL is used to swap the elements of one multimap to another of same size and type.AlgorithmBegin Declaring two empty map container m, m1. Insert some values in both m, m1 map containers. Perform swap() function to swap the values of m, m1 map containers. Printing the swapped values of m map container. Printing the swapped values of m1 map container. End.Example Code Live Demo#include #include using namespace std; int main() { unordered_map m, m1; // declaring m, m1 as empty map container m.insert (pair('b', 10)); ... Read More
60 Views
unordered_multimap size() function in C++ STL returns the number of elements in the unordered map.AlgorithmBegin Declare an empty map container m. Performing reserve function to restrict the most appropriate bucket_count of the map container. Insert values in the map container. Print the size of the unorderd multimap container by using the size() function. EndExample Code Live Demo#include #include using namespace std; int main() { unordered_map m; // declaring m as empty map container m.reserve(6); //restricting the most appropriate bucket_count of map container m.insert (pair('b', 10)); // inserting some values m.insert (pair('a', 20)); cout
96 Views
The unordered_multimap reserve() function in C++ STL sets the number of buckets in the container to the most appropriate number so that it contains at least n elements.If n is greater than the current numbers of bucket multiplied by the max_load_factor, the container’s number of buckets is increased and a rehash is forced.Reserve () returns nothing and take n as a parameter which specifies the minimum number of elements as per requested minimum capacity.AlgorithmBegin Declare the vector m. m.reserve(6) = the size is reserved for the bucket to contain minimum number of one elements. Insert the key ... Read More
39 Views
The unordered_multimap rehash(N) function in C++ STL sets the number of buckets in the container to n or more. A rehash is forced if n is greater than the current number of buckets in the container. The new bucket count can either be equal to or greater than n. The function may have no effect on the bucket count and may not force a rehash if n is lower than the current number of buckets in the container. Rehash () returns nothing and take n as a parameter which specifies the minimum number of buckets for the container hash table.AlgorithmBegin ... Read More
512 Views
STL Priority Queue is the implementation of maxheap.This is a C++ program of STL priority queue for structure.AlgorithmBegin Define a structure of type student. Initialize variables in student structure. Define another structure of type comparemarks Overload the variables of student structure in comapremarks structure. Use priority queue with structure. Insert some elements in priority queue using student structure. While the queue is not empty do Print the elements. End.Example Code Live Demo#include #include using namespace std; #define ROW 6 #define COL 3 struct student { //defining the student ... Read More
To Continue Learning Please Login
Login with Google