C++ PROGRAMMING – FULL CHAPTER NOTES
(KitabCD Style | Class 11)
Introduction to Programming
A program is a set of well-defined instructions written to perform a specific task using a computer. Programming is
the systematic process of writing, testing, debugging, and maintaining programs to solve problems logically.
Programming Languages
Programming languages are used to communicate instructions to a computer. Based on their level, they are
classified as:
Machine Language
• Uses binary digits (0 and 1)
• Directly understood by computer hardware
• Fastest execution
• Very difficult to write and debug
• Machine dependent
Assembly Language
• Uses mnemonic codes like ADD, SUB, MOV
• Requires an assembler to convert into machine language
• Easier than machine language
• Still machine dependent
High-Level Language
• English-like syntax
• Easy to write, read and debug
• Machine independent
• Examples: C, C++, Java, Python
What is C++
C++ is a general-purpose, object-oriented programming language developed by Bjarne Stroustrup. It is an
extension of the C language with added OOP features.
Features of C++
• Object-Oriented Programming support
• High performance and fast execution
• Portable and machine independent
• Rich library support
• Supports low-level and high-level programming
Object-Oriented Programming Concepts
OOP is a programming approach based on objects rather than functions.
Class
A class is a blueprint or template that defines the properties (data members) and behaviours (member functions)
of objects.
Object
An object is a real-world entity and an instance of a class.
Encapsulation
Encapsulation refers to binding data and functions together into a single unit using classes.
Abstraction
Abstraction means showing only essential features and hiding internal implementation details.
Inheritance
Inheritance is the process by which one class acquires the properties of another class, promoting code reusability.
Polymorphism
Polymorphism allows the same function or operator to perform different operations based on context.
Advantages of C++
• Code reusability
• Faster execution speed
• Better memory management
• Large community support
Structure of a C++ Program
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World";
return 0;
}
Explanation of Program Structure
• Header file includes predefined functions
• main() is the entry point of the program
• cout is used for output
• return 0 terminates the program
Tokens in C++
Tokens are the smallest individual units of a C++ program.
Types of Tokens
• Keywords
• Identifiers
• Constants
• Operators
• Special symbols
Keywords
Keywords are reserved words with predefined meanings. Example: int, float, if, else, while.
Identifiers
Identifiers are names given to variables, functions, arrays, etc. They must follow naming rules and cannot be
keywords.
Constants
Constants are fixed values that do not change during program execution. Types include integer, floating, character
and string constants.
Variables
A variable is a named memory location used to store data values. Variables must be declared before use.
Data Types in C++
Basic data types include int, float, double, char and bool.
Operators
Operators are symbols used to perform operations on data.
Types of Operators
• Arithmetic operators (+, -, *, /, %)
• Relational operators (<, >, ==, !=)
• Logical operators (&&, ||, !)
• Assignment operators (=, +=, -=)
• Increment and Decrement operators (++ , --)
Input and Output Statements
cin is used to take input from user and cout is used to display output.
Control Statements
Control statements are used to control the flow of execution of a program.
Conditional Statements
if, if-else and else-if ladder are used for decision making.
Looping Statements
for, while and do-while loops are used for repetitive execution of statements.
Jump Statements
break is used to exit loop, continue skips iteration, return exits function.
Comments in C++
Comments improve program readability. Single-line comments use // and multi-line comments use /* */.
Header Files
Header files contain predefined functions and definitions. Examples: iostream, math.h, string.h
Errors in C++
• Syntax errors – grammatical mistakes
• Runtime errors – occur during execution
• Logical errors – incorrect logic
Exam Important Points
■ C++ is case-sensitive
■ main() is compulsory
■ Every statement ends with semicolon
■ Logical errors do not stop execution
Conclusion
C++ is a powerful, flexible and widely used programming language that supports both procedural and
object-oriented programming.