To prepare programs on a linux machine, follow the instructions given below:
  1. Open two linux terminals.
  2. In the first terminal create a directory using the command: mkdir DIRNAME (followed by pressing the Enter key) where DIRNAME stands for the name you wish to give to the directory.
  3. Enter that directory using the command: cd DIRNAME (followed by pressing the Enter key)
  4. Open an editor inside that directory using the command: nano FILENAME.cpp (press Enter)
  5. Type in the program in the nano editor. Periodically save the file using Ctrl-O and pressing enter.
  6. If you need to quit the nano editor, press Ctrl-X.
  7. In the other terminal enter the directory using the command: cd DIRNAME
  8. Compile the program using the command: g++ -o FILENAME.o FILENAME.cpp
  9. If there is no syntax error, the executable file FILENAME.o will be produced.
  10. Run this executable file using ./FILENAME.o
  11. If there is one or more syntax errors, then g++ will report these errors and associated line numbers . These line numbers refer to lines inside FILENAME.cpp. In such a case, you should go to those line numbers inside the nano editor with FILENAME.cpp opened, and try to rectify those syntax errors. To determine a line number, press Ctrl-C inside nano. It will show you the line number for the cursor's position at the bottom of the screen. After you have rectified the syntax errors, you will need to recompile the program.
For those using a windows machine, you can install Cygwin which simulates Linux terminals and programs on Windows. Instructions for installing Cygwin can be found on the class webpage. Once you have Cygwin, you can all the aforementioned tools, exactly as if it were a Linux machine.