🚀 Getting Started with C++
Ready to write your first line of C++ code? You’re in the right place! In this guide, you’ll set up your computer and run your first simple program: Hello, World!
Let’s jump in and make that computer talk to us in C++! 😄
💻 Step 1: Install a C++ Compiler
To run C++ programs, you need a compiler. Here are some options:
- 🪟 Windows: Install Code::Blocks with MinGW
- 🍎 Mac: Install Xcode Command Line Tools using
xcode-select --install - 🐧 Linux: Use the terminal:
sudo apt install g++
🛠️ Step 2: Choose an Editor
You can write C++ code in any text editor, but it’s best to use an IDE or smart editor:
- Code::Blocks (easy for beginners)
- Visual Studio (powerful but heavier)
- VS Code (lightweight and flexible)
👨💻 Step 3: Your First C++ Program
Let’s write the classic “Hello, World!” program. This is like saying “Hi!” to the programming world.
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
return 0;
}
🔎 What’s Happening Here?
#include <iostream>– Includes input-output libraryusing namespace std;– So we don’t have to writestd::before things likecoutint main()– The starting point of every C++ programcout << "Hello, World!"– Prints text to the screenreturn 0;– Says “all good” when the program ends
✅ Output:
Hello, World!
🎉 You’re Officially a C++ Programmer!
That’s it! You wrote your first C++ program. It may seem small, but this is how every great programmer started — one line at a time. 🚀
🔗 What’s Next?
Now that you know how to write and run a C++ program, let’s dive deeper into variables, data types, and fun stuff! Up next:
👉 C++ Variables and Data Types