C++ is a general-purpose, object-oriented programming language that builds upon the foundation of the C programming language.
It allows you to create efficient and maintainable code while offering high-level abstractions.
Frequently Asked Question
Compared to C++, there are many popular programming languages that are far easier to use and understand.
However, C++ is still used today because of its superior performance, fine-grained control over hardware, and rich legacy of libraries and applications.
These features make C++ the ideal language for the development of
- Video Games
- Operating systems
- Web Browsers
- System Software
- and many more.
How to Run C++ Programs
We have two options to run C++ programs:
- Using an online environment.
- Installing a C++ environment in your computer.
Run C++ in an Online Environment
The easiest way to run C++ is to use an online compiler. There are tons of C++ compilers that you can find with a simple Google search.
To use C++ using an online compiler, go to Programiz Online Compiler for C++ and type the following code.
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
Now, just press the Run button and you should see Hello, World!
printed to the output window.
The output window will look like this:
Install a C++ Environment on Your Computer
To run C++ programs on your computer, you will need two things:
- A C++ Compiler
- A code editor or an IDE (Integrated Development Environment)
Some popular C++ compilers include:
Code Editors
Code editors are lightweight software you can use to write and edit your C++ code. However, you usually need to install the relevant plugins and extensions before you can run your C++ code.
Some popular code editors are:
Integrated Development Environments (IDEs)
While you can write C++ code in a simple text editor, using an Integrated Development Environment can significantly enhance your productivity. Some popular C++ IDEs include:
You can choose any of the available options we've provided above.
However, we will be teaching you how to set up a C++ environment in VS Code. We favor VS Code over other options thanks to its performance, versatility, and beginner-friendly interface.
C++ Development Environment in Visual Studio Code
Follow the steps below to install Visual Studio Code in your local machine:
- Get the installation file suitable for your OS from this download link.
- Run the installation file and follow the installation wizard.
- Once you have installed VS Code in your machine, open it and go to extensions (
Ctrl + Shift + X
). - In the Extensions tab, search for C++.
- Select Install.
Compilers come preinstalled on most platforms (like GCC on Linux and Clang on macOS).
However if you don't have one preinstalled on yours, then follow the instructions here after you have installed VS Code.
Note: To run the program from earlier in this local environment, save your program file with a .cpp
extension (e.g., hello.cpp) and build/run it.
Frequently Asked Question
C++ is an extension of the C programming language. Unlike C programming, C++ supports object-oriented programming (OOP) as well as advanced data structures and algorithms with the Standard Template Library (STL).