6 AnswersNew Answer
In visual studio run your code with ctrl-F5 or add an extra Console.ReadLine at the end of the code. Your code has run, but also closed before you could see the results.
I used control+f5 to execute my code, but I cant see the result it disappeare very fast
First clear this for me You are talking about visual studio code or visual studio IDE
if control f5 is not working, have a look at the following video. https://www.youtube.com/watch?v=F82W3pv87Hk There is a visual studio setting which need to be set. quote : Please right click your project name and go to Properties page, please expand Configuration Properties -> Linker -> System, please select Console (/SUBSYSTEM:CONSOLE) in SubSystem dropdown. Because, by default, the Empty project does not specify it. https://stackoverflow.com/questions/2529617/how-to-stop-c-console-application-from-exiting-immediately If all above does not work. Add one of the following lines just before return; (last line of you code) system("pause"); And of course not Console.ReadLine (c#) but cin.get(); (C++)
Use cin.get () as last line of the main function or you can use system ("pause"); on windows