Introduction to C++

C++ 152 views Dec 22, 2025 2 min read

C++ is a general-purpose programming language created by Bjarne Stroustrup. It is an extension of the C language and supports both procedural and object-oriented programming.

C++ is widely used for:

  • System software (operating systems, drivers)

  • Game development ????

  • Desktop applications

  • Embedded systems

  • High-performance applications


Key Features of C++

  • Fast and efficient 

  • Object-Oriented (classes, objects, inheritance)

  • Low-level memory control (using pointers)

  • Portable (can run on different platforms)

  • Rich Standard Library


Basic Structure of a C++ Program

#include using namespace std; int main() { cout << "Hello, World!"; return 0; }

Explanation:

  • #include → Allows input/output operations

  • using namespace std; → Avoids writing std:: repeatedly

  • int main() → Entry point of the program

  • cout → Used to print output

  • return 0; → Ends the program successfully


Input and Output

int age; cin >> age; // Input cout << age>// Output
  • cin → Input from user

  • cout → Output to screen


Variables and Data Types

Common data types in C++:

TypeExample
int10
float3.14
double3.14159
char'A'
booltrue / false
string"Hello"

Example:

int number = 5; float price = 99.99; char grade = 'A';

Control Statements

If-Else

if (x > 0) cout << "Positive"; else cout << "Negative";

Loops

For Loop

for (int i = 1; i <= 5; i++) cout << i>" ";

While Loop

int i = 1; while (i <= 5) { cout << i>" "; i++; }

Functions

int add(int a, int b) { return a + b; }

Functions help divide programs into smaller, reusable parts.


Object-Oriented Programming (OOP)

Class and Object

class Student { public: string name; int age; };
Student s1; s1.name = "John"; s1.age = 20;

Why Learn C++?

  • Foundation for learning other languages

  • Used in competitive programming 

  • Powerful for performance-critical applications

  • Strong understanding of memory and system design

Some advanced sections are available for Registered Members
Share this Post
🚀 Want to Test Your Knowledge?

Take quizzes related to this topic and see where you stand!

Start Quiz Now
Back to Tutorials