C++ Programs Typing And Execution

All programming language programs can be written using a text editor. C++ Program files extension is '.cpp'.

C++ Programs Typing And Execution

C++ programs can be written using any text editor. We need to compile our C++ program files using a compiler. Some software such as CodeBlocks, Turbo C++, DevC++, etc provides an Integrated Development Environment (IDE) for developing programs easily and efficiently. These IDEs provide features like typing, editing, searching, compiling, etc. integrated into one package. For every IDE there are different ways to use their features so before using any IDE we should refer its complete documentation provided by the developers.

For running a C++ program successfully we need to take care of proper file extension of the C++ program file. C++ implementation uses several extensions but the most common one is ".cpp".

In this C++ course series, we will be using CodeBlocks, you can choose any IDE for executing your programs for that you can refer the documentation of that IDE but we will be discussing only CodeBlocks.

Working with CodeBlocks

Code::Blocks is a free and open-source, cross-platform IDE. It can be downloaded from www.codeblocks.org. You can follow the step given on the code blocks website for installing it.

After installing code blocks, you can type and execute your C++ program in it by following the steps given below:

  1. Start CodeBlocks.You'll see a window similar to the image given below:

  2. Now to type a new C++ program, click File->New->Empty->File or you can use a keyboard shortcut Ctrl+Shift+N.

  3. In the right pane, you'll find space opened namely *Untitled, where ( * ) indicates that the file is unsaved. You can type our program in this right pane.

  4. Now to save your code, we can use the keyboard shortcut Ctrl+S or you can go to File-> Save file command. It will ask you to specify the file name. Specify file name wth extension .cpp, it might take a default extension of C/C++ files which is .c.

  5. After saving the file you can notice that our file name is changed from *Untitled to program1.cpp. This means our file successfully saved and remember if you will make any changes in the file then (*) will appear before the file name so keep saving your program frequently before running your program.

  6. Once the file is saved you can compile and run your program by using the command on the Build menu. To compile, click Build->Compile current file, or you can use the keyboard shortcut Ctrl+Shift+F9.
  7. If you want to build and run, click Build-> Build and run command or you can use the keyboard shortcut F9.
  8. If you encounter any error in your program fix them, resave your program, and re-compile and re-run it.

Now, We will stop here in this tutorial and will study the role of the compiler in the next tutorial. If you have any query drop your comment in the comment section. 

(Note: You can see the full image by clicking on them.)

What's Your Reaction?

like
1
dislike
0
love
1
funny
0
angry
0
sad
0
wow
1