#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout << "Print two numbers: ";
int x, y;
cin >> x >> y;
cout << x << y;
return 0;
}
Input : 23 24
Output : Print two numbers: 2324
Here before printing the line "Print two numbers: " on console, stdin is waiting for x and y, then prints the entire output on console as given above.
After removing sync lines from above code:
#include <iostream>
using namespace std;
int main()
{
// ios::sync_with_stdio(0);
// cin.tie(0);
cout << "Print two numbers: ";
int x, y;
cin >> x >> y;
cout << x << y;
return 0;
}
Here first it's printing line "Print two numbers: " on console then stdin stream is waiting for x and y.
I am unable to understand this behaviour.