Do we have to put a new line and space after main function?
No.
However, some compilers object if the final line of your source code is not properly terminated; eg,
// your code : : }<EOF>
(where <EOF> means the end of the file).
So they want to see:
// your code : : } <EOF>
makes sense many thankss
If that's resolved your question, please verify the answer: