
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
set lower_bound() function in C++ STL
Set lower_bound() function in C++ STL returns an iterator pointing to the element in the container which is equivalent to k passed in the parameter. If k is not present in the set container, then the function returns an iterator pointing to the immediate next element which is just greater than k.
Algorithm
Begin Initialize an empty set container s. Initializing a set container as inetrator. Insert some elements in s set container. Call function to find the lower bound value of a given key, which is passed to iter set container. Print the lower bound value of the given key. End.
Example Code
#include<iostream> #include <bits/stdc++.h> using namespace std; int main() { set<int> s; //Declaring an empty set container set<int>::iterator iter; //Declaring a set container as iterator which will point to the lower bound value s.insert(7); //inserting elements in the set container s s.insert(6); s.insert(1); s.insert(4); s.insert(2); s.insert(9); s.insert(10); iter = s.lower_bound(4); //passing a key by parameter to find its lower bound cout <<"The lower bound of 4 is: "<< *iter << " "<<endl; //printing the lowerbound value iter = s.lower_bound(5); cout <<"The lower bound of 5 is: " <<*iter << " "<<endl; iter = s.lower_bound(30); cout <<"The lower bound of 30 is: " <<*iter << " "<<endl; return 0; }
Output
The lower bound of 4 is: 4 The lower bound of 5 is: 6 The lower bound of 30 is: 7
- Related Articles
- Lower bound in C++
- Upper bound and Lower bound for non increasing vector in C++
- Integrate a polynomial and set the lower bound of the integral in Python
- Python – Custom Lower bound a List
- Integrate a Laguerre series and set the lower bound of the integral in Python
- Integrate a Hermite series and set the lower bound of the integral in Python
- Integrate a Chebyshev series and set the lower bound of the integral in Python
- Integrate a Legendre series and set the lower bound of the integral in Python
- Integrate a Hermite_e series and set the lower bound of the integral in Python
- Set find() function in C++ STL
- Set emplace_hint() function in C++ STL
- Set equal_range() function in C++ STL
- Set count() function in C++ STL
- Set max_size() function in C++ STL
- Set upper_bound() function in C++ STL

Advertisements