multiset size() in C++ STL with Examples


In this tutorial, we will be discussing a program to understand multiset size() in C++ STL.

The function size() returns the number of elements present into a given container.

Example

 Live Demo

#include <bits/stdc++.h>
using namespace std;
int main(){
   multiset<int> s;
   s.insert(10);
   s.insert(13);
   cout << "The size of multiset: " << s.size();
   s.insert(13);
   s.insert(25);
   cout << "\nThe size of multiset: " << s.size();
   s.insert(24);
   cout << "\nThe size of multiset: " << s.size();
   return 0;
}

Output

The size of multiset: 2
The size of multiset: 4
The size of multiset: 5

Updated on: 06-Apr-2020

72 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements