C++ Introduction


🔹 What is C++?

C++ is a powerful, high-performance object-oriented programming language. It is an extension of C, developed by Bjarne Stroustrup at Bell Labs in the early 1980s.

It supports:

  • Procedural and object-oriented programming

  • Low-level memory manipulation

  • System-level and application-level development


🔹 Why Learn C++?

  • Combines the power of C with modern object-oriented features

  • Used in game development, operating systems, browsers, and more

  • Highly efficient and fast

  • Rich library support and portability

  • Foundation for many competitive programming problems


🔹 Features of C++

  • Object-Oriented (supports classes, objects, inheritance, etc.)

  • Statically typed and compiled language

  • High performance

  • Supports both procedural and object-oriented paradigms

  • Allows low-level manipulation via pointers


🔹 How to Get Started with C++

✅ Requirements:
  • A C++ compiler like g++

  • An IDE or text editor (Code::Blocks, VS Code, etc.)


🔹 First C++ Program

#include <iostream>
using namespace std;

int main() {
    cout << "Hello, World!";
    return 0;
}
🔸 Explanation:
 
  • #include <iostream> — Header for input/output

  • using namespace std; — Avoids prefixing std:: with functions like cout

  • main() — Program execution starts here

  • cout — Outputs to the console

  • return 0; — Ends the program


🔹 Compiling and Running C++ Program
✅ Using g++:
g++ program.cpp -o program
./program
 

Practice Questions

Q1. Print your name in C++

Q2. Add two numbers.

Q3. Use comments in a C++ program.

Q4. Input and output a number.

Q5. Multiply two floating-point numbers.


Go Back Top