Back to Course

Introduction to C++

0% Complete
0/0 Steps
  1. C++: Basics
    6 Quizzes
  2. C++: Compilation and Execution
    6 Quizzes
  3. C++: Variables
    10 Quizzes
  4. C++: Conditions Operators
    6 Quizzes
  5. C++: Logical Operators
    4 Quizzes
  6. C++: Loops and Errors
    9 Quizzes
  7. C++: Vectors
    3 Quizzes
Lesson 2, Topic 2
In Progress

C++: Compile and Execute

Yasin Cakal 30 Oct 2021
Lesson Progress
0% Complete


A compiler helps convey our codes to the computer by converting them into machine codes. You can open a compiler using a terminal. It might display $ a sign right now. To call on the compiler to compile a program, type g++ followed by a file name to compile a specific file. Then press the enter key. Make sure the file name contains the file extension .cpp.

To begin practising this, save your Hello, World! program file by the name of hello world.cpp. Now, type g++ and the file name like shown below:

g++ hello world.cpp

This will enable the compiler to convert the C++ program file into a machine code file. This machine code file is given a default name a.out.


Type ./ followed by the machine code file name to execute it. An example for this is:


This will load the file to computer memory enable the CPU to execute the program according to the instructions

Now, try compiling a program using the terminal!.


Leave a Reply

%d bloggers like this: