Introduction to C++

πŸ“˜ C++ πŸ‘ 41 views πŸ“… Dec 22, 2025
⏱ Estimated reading time: 2 min

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
Register Now

Share this Post


← Back to Tutorials

Popular Competitive Exam Quizzes