... ArdiLand Institute of Technology C++ Programming Language – Complete Guide for Beginners | Ardiland Institute of Technology
540-440-1540‬
USD ($)
$
United States Dollar
Br
Ethiopian Birr

C++ Programming Language – Complete Guide for Beginners

Created by Adugna Asrat in Quick Notes 27 Mar 2025
Share

🚀 What is C++?

C++ is a high-performance, compiled, object-oriented programming language created by Bjarne Stroustrup. It is widely used for system software, game engines, embedded systems, and competitive programming.

✅ Supports both procedural and object-oriented programming
✅ Provides fine control over memory with pointers
✅ Used in operating systems, browsers, finance, robotics, and more


🧱 1. Variables and Data Types

What is a Variable?

A variable stores data in memory. You must declare the type before using it.

Example:

int age = 21;

string name = "Maya";

To use strings in C++, include the string header:

#include <string>


What are Data Types?

int – Whole numbers
float / double – Decimal values
char – A single character
bool – True or False
string – A sequence of characters (text)


🔢 2. Input and Output

Output (printing to screen):

cout << "Hello Ardiland!";

Input (user typing a value):

int age;

cin >> age;

To use cin and cout, include:

#include <iostream>

using namespace std;


🔍 3. Conditional Statements and Loops

Conditional Statements

Used to run code based on a condition.

if (age >= 18) {

    cout << "You are an adult.";

} else {

    cout << "You are a minor.";

}


Loops

For Loop:

for (int i = 0; i < 5; i++) {

    cout << i << " ";

}

While Loop:

int i = 0;

while (i < 5) {

    cout << i << " ";

    i++;

}


🧠 4. Functions

A function is a reusable block of code that performs a task.

void greet(string name) {

    cout << "Hello " << name;

}

To call the function:

greet("Maya");


🧱 5. Object-Oriented Programming (OOP)

What is a Class?

A class is a blueprint for objects. It groups variables (data) and methods (functions).

class Student {

public:

    string name;

    int age;

};

What is an Object?

An object is an instance of a class.

Student s1;

s1.name = "Christian";

s1.age = 22;


OOP Concepts in C++

Encapsulation – Keep data safe using access specifiers (private, public)
Inheritance – One class can inherit from another
Polymorphism – Same function behaves differently based on context
Abstraction – Hide implementation details and show only essentials


📚 6. Arrays

An array stores multiple items of the same type.

int scores[3] = {90, 85, 78};

cout << scores[0]; // Output: 90


🛡️ 7. Exception Handling (Basic)

To catch runtime errors:

try {

    throw "Something went wrong!";

} catch (const char* msg) {

    cout << msg;

}

Note: C++ uses exceptions less frequently than Java or Python. Often, programmers check manually for errors.


🌐 Applications of C++

✅ Operating systems (Windows, macOS, Linux kernel modules)
✅ Game engines (Unreal Engine)
✅ Embedded systems (microcontrollers, IoT)
✅ Real-time systems (telecom, robotics, trading systems)
✅ Competitive programming (for speed and memory control)



Comments (0)

Share

Share this post with others