- 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++
140 Views
The multiset insert() function in C++ STL which insert elements in the multiset container from a position to another position from one multiset to a different multiset.List of functions used:ms.size() = Returns the size of multiset. ms.insert() = It is used to insert elements to the multiset.Example Code#include #include #include #include using namespace std; int main() { multiset ms; multiset::iterator it, it1; int c, i; while (1) { cout
81 Views
lldiv() function in C++ STL gives the result of quotient and remainder of the division of the two numbers.AlgorithmBegin Take two long type numbers as input. Call function lldiv(). Print the quotient and remainder. End.Example Code#include #include using namespace std; int main() { long long q = 500LL; long long r = 25LL; lldiv_t res = lldiv(q, r); cout
80 Views
iswalpha() function in C++ STL is used to check whether the given wide character is an alphabet or not.AlgorithmBegin Initializes the strings. Call function iswalpha(str) to check whether it contains alphabet or not. If it contains alphabet, then value will be returned otherwise zero will be returned. EndExample Code#include #include #include #include using namespace std; int main() { setlocale(LC_ALL, "ab1234"); wchar_t s[] = L"a%$^^&)"; bool flag = 0; for (int i=0; i
121 Views
iswalnum() function in C++ STL checks if the given wide character is an alphanumeric character, i.e. either a number (0-9), an uppercase letter(A-Z), a lowercase letter (a-z) or any alphanumeric character or not.AlgorithmBegin Initializes the characters. Call function iswalnum(c1) to check whether it is alphanumeric or not. If it is alphanumeric character, then value will be returned otherwise zero will be returned. EndExample Code#include #include using namespace std; int main() { wchar_t c1 = '/'; wchar_t c2 = 'a'; if (iswalnum(c1)) wcout
653 Views
InsertionInsertion in STL set can be done by insert() and emplace() operation.Insert(): Insert() is used to insert elements to the set. Insert operation takes a reference to an object.List of functions are used:st.size() = Returns the size of set. st.insert() = It is used to insert elements to the set.Example Code#include #include #include #include using namespace std; int main() { set st; set::iterator it; int c, i; while (1) { cout
564 Views
Erase function is used to remove an item from a C++ STL vector with a certain value.AlgorithmBegin Declare vector v and iterator it to the vector. Initialize the vector. Erase() function is used to remove item from end. Print the remaining elements. End.Example Code#include #include using namespace std; int main() { vector v{ 6,7,8,9,10}; vector::iterator it; it = v.end(); it--; v.erase(it); for (auto it = v.begin(); it != v.end(); ++it) cout
925 Views
emplace operation avoids unnecessary copy of object and does the insertion more efficiently than insert operation. Insert operation takes a reference to an object.AlgorithmBegin Declare set. Use emplace() to insert pair. Use insert() to insert pair by using emplace(). Print the set. EndExample Code#include using namespace std; int main() { set s; s.emplace(7, 'a'); s.insert(make_pair(6, 'b')); for (auto it = s.begin(); it != s.end(); ++it) cout
3K+ Views
Generally, the default behavior of map and multimap map is to store elements is in ascending order. But we can store element in descending order by using the greater function.The map in descending order:Functions are used here -m::find() – Returns an iterator to the element with key value ‘b’ in the map if found, else returns the iterator to end.m::erase() – Removes the key value from the map.m:: equal_range() – Returns an iterator of pairs. The pair refers to the bounds of a range that includes all the elements in the container which have a key equivalent to key.m insert() ... Read More
381 Views
Vectors have the ability to resize itself automatically like dynamic arrays when an element is inserted or deleted, the container handle their storage automatically. Vector elements are placed in contiguous storage so that they can be accessed and traversed using iterators. Data can be inserted or erased at the begin, middle or end of the vector.Functions and descriptions:List of functions used here: v.size() = Returns the size of vector. v.push_back() = It is used to insert elements to the vector from end. v.pop_back() = To pop out the value from the vector from back. v.capacity() = ... Read More
798 Views
Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be FILO (First In first out) or LIFO (Last In First Out)AlgorithmBegin Declare stack vector. Take the input as per choice. Call the functions within switch operation: s.size() = Returns the size of stack. s.push() = It is used to insert elements to the stack. s.pop() = To pop out the value from the stack. s.top() = Returns a ... Read More
To Continue Learning Please Login
Login with Google