in C++

Last Updated : 4 Apr, 2026

<bits/stdc++.h> is a non-standard header file provided by the GCC that allows developers to include multiple standard C++ libraries using a single line of code. It is widely used in competitive programming to speed up development.

However, since it is not part of the C++ standard, it is not portable and should be avoided in production-level software.

  • Works only with GCC-based compilers (not supported in MSVC)
  • Increases compilation time due to inclusion of unnecessary headers

Example: To use the sqrt() function, you do not need to include the <cmath> header separately if <bits/stdc++.h> is already included.

C++
#include <bits/stdc++.h>
using namespace std;

int main() {

    cout << sqrt(25); 
    return 0;
}

Output
5

But if we use <iostream> header file, we have to write <cmath> header file to run the sqrt( ) function otherwise compiler shows that 'sqrt' was not declared in this scope.

C++
#include <iostream>
#include <cmath>
using namespace std;

int main() {

    cout << sqrt(25);
    return 0;
}

Output
5

So, the user can either use it and save the time of writing every include or save the compilation time by not using it and writing necessary header files. 

AdvantagesDisadvantages
Reduces time spent writing multiple #include statementsIncludes many unnecessary headers
Useful in competitive programming where speed mattersIncreases compilation time
No need to remember specific headers for each functionNot part of standard C++ (non-portable)
Simplifies quick prototypingNot supported by compilers like Microsoft Visual Studio (MSVC)
Comment