This is because of the output buffer.
The buffer hasn't been emptied yet, so it looks like scanf came out before the output.
fflush(stdout);
Force the buffer to empty using fflush before scanf.
I am attaching a link for your reference.
C language coding painting: utilizing input/output buffers
549 PHP ssh2_scp_send fails to send files as intended
547 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
534 Uncaught (inpromise) Error on Electron: An object could not be cloned
542 Unable to install versioned in Google Colab
703 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.