In C++, the list::push_front() function is used to insert a new element at the beginning of the list container. Whenever a new element is inserted using this function, the size of the list increases by one.

It is commonly used when elements need to be added at the front of the list efficiently. Since lists are implemented as doubly linked lists, insertion at the beginning is fast and does not invalidate iterators or references.
It has the following syntax.
x: It is the value to be inserted in the beginning of the list.
It does not return any value.
Here, we are going to discuss several examples to demonstrate the List push_front() Function Function.
This example demonstrates how to insert an integer element at the beginning of a list using the push_front() function.
Output:
10,20,30,40,50
Explanation:
In this example, push_front() function inserts the element '10' in the beginning of the list.
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India