Before writing your first C++ program, you need to install a C++ compiler on your computer. A compiler converts your C++ code into a machine-readable program that your computer can execute.
There are many C++ compilers available, but beginners commonly use Code::Blocks, Visual Studio Code (VS Code), or Visual Studio.
Install Code::Blocks (Recommended for Beginners)
Follow these steps to install Code::Blocks:
- Download the Code::Blocks installer with the MinGW compiler included.
- Run the installer and follow the installation wizard.
- Complete the installation and launch Code::Blocks.
- Create a new C++ project or open a new source file.
- You are now ready to write and run your first C++ program.
Install Visual Studio Code
To use C++ in Visual Studio Code:
- Install Visual Studio Code.
- Install the C/C++ extension.
- Install the MinGW or MSYS2 compiler.
- Configure the compiler in VS Code.
- Create a new
.cppfile and start coding.
Key Points
- A compiler is required to run C++ programs.
- Code::Blocks is a good choice for beginners because it includes the compiler.
- VS Code is lightweight and widely used by developers.
- Save your C++ programs with the
.cppextension.
Written by Shubhranshu Shekhar, who has trained 20000+ students in coding.