Sir this is my code sir this is my code

sir this is my code pls solve my doubt

yes code is correct

and i think your doubt regarding use of cin.get() is clear
cin.get() will consume the last whitespace, which you have entered after providing n
so that cin.getline() will not consider it as a string

what is your doubt Now?

now i am marking your doubt as resolved
plz give your feedback from link given below