Sort inbuilt()i am having one question

Iostream don’t have the sort function in it…how sir is doing the code without using the bits librrary. becoz in my IDE sort is not declared under iostream???

#include
using namespace std;

int main()
{
int a[] = {1, 2, 4, 5, 3};
int n = sizeof(a) / sizeof(a[0]);
for (int i = 0; i < n; i++)
{
cout << a[i] << " ";
}
cout << endl;

sort(a,a+n);

for (int i = 0; i < n; i++)
{
    cout << a[i] << " ";
}

return 0;

}

@abhinavssr2003_eab0717682969e5c u need to include #include <algorithm> or bits thing else it will show error

read here https://stackoverflow.com/questions/49760728/i-dont-use-algorithm-header-but-sort-is-available

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

But how sir is doing in his video

LIke we have to inc algo or bits…but sir code is working absolutely fine without any of these…how is it possible sir?

@abhinavssr2003_eab0717682969e5c,
In C++, including any standard header is allowed (but certainly not required) to have the same effect as including any or all other standard headers.

In this case, it appears that some part of the implementation of <iostreams> used an algorithm from <algorithm> , so your inclusion of <iostreams> accidentally included <algorithm> as well.

Of course, you don’t want to depend on this–on a different implementation, your code can (and often will) fail. Even updating your compiler (or possibly even just using different compiler flags) could prevent your code from compiling.

@abhinavssr2003_eab0717682969e5c still have doubt?

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.