Theme images by Storman. Powered by Blogger.

Saturday 20 August 2016

Compile & Execute C++ Program


 Let's look at how to save the file, compile and run the program. 

Please follow the steps given below:

  • Open a text editor and add the code as above.
  • Save the file as: hello.cpp
  • Open  a  command  prompt  and  go  to  the  directory  where  you  saved  the file.

  • Type 'g++ hello.cpp' and press enter to compile your code. If there are no errors  in  your  code  the  command  prompt  will  take  you  to  the  next  line and would generate a.out executable file.

  • Now, type 'a.out' to run your program.
  • You will be able to see ' Hello World ' printed on the window
       $ g++hello.cpp
       $ ./a.out
       HelloWorld
  • Make sure that g++ is in your path and that you are running it in the directory containing file hello.cpp

0 on: "Compile & Execute C++ Program"