CPP Programming

Introduction to C++

C++ Basics

Control Flow

Collections & Memory

Functions

Object-Oriented Programming

File Handling & Date

Error Handling & Validation

STL & Data Structures

Namespaces

CPP Programming

Introduction to C++

C++ Basics

Control Flow

Collections & Memory

Functions

Object-Oriented Programming

File Handling & Date

Error Handling & Validation

STL & Data Structures

Namespaces

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.


C++ Introduction Quiz

Q1: Who developed C++?

A. Dennis Ritchie
B. James Gosling
C. Bjarne Stroustrup
D. Guido van Rossum

Q2: What is the correct syntax to output text in C++?

A. print("Hello")
B. echo "Hello"
C. cout << "Hello";
D. System.out.println("Hello");

Q3: Which of the following is a correct C++ comment?

A. /* This is a comment */
B. // This is a comment
C. Both A and B
D. None

Q4: What is the file extension of a C++ source file?

A. .c
B. .java
C. .cpp
D. .py

Q5: What is the use of #include <iostream>?

A. For math functions
B. For input and output operations
C. For file handling
D. For graphical operations

Go Back Top