I have written a simple code in C++. But suddenly i got one weird behavior by the output of my code. I am not getting why i am getting this type of problem here.
Below is My Simple C++ Code :
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout<<"Hi\n";
lli a[] = {1,2,3,4,5,6,7};
cout<<"Original Array : ";
for(int i=0;i<7;i++)
cout<<a[i]<<" ";
lli q;
cout<<"\n\nEnter q : ";
cin>>q;
cout<<"q = "<<q<<"\n";
}
The weird behavior is this : Whenever i am running my code. It is not printing any output message "Hi..and all". It seems it is directly asking for the input of used "q" variable ( below ) first. Then it is printing the required output. I am very much confused by this behavior. Please tell me why my code is asking for the input of q first. And then it is showing original behavior.
Below is the output of my code :
Note : Whenever i am removing these three lines :
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
It is behaving perfectly as required. I am not getting Why.