C++ PROGRAMMING
Smart Computing Department
Fall-2026
Introduction to Computer and Programming
Smart Computing Department 2
Why Program?
❑ Concept
Computers can do many different jobs because they are programmable
Computers are not designed to do just one job, but
To do any job that their programs tell them to do
❑ Program
It is a set of instructions that a computer follows to perform a task
Examples are: MS-Word, Power-point, etc.
Programs are commonly referred to as software
Software is essential to a computer because without software, a computer can do nothing
Software are created by individuals known as programmers or software developers
A programmer is a person with the training and skills necessary to create programs
Smart Computing Department 3
Why Program?
❑ Concept
Computers can do many different jobs because they are programmable
Computers are not designed to do just one job, but
To do any job that their programs tell them to do
❑ Program
It is a set of instructions that a computer follows to perform a task
Examples are: MS-Word, Power-point, etc.
Programs are commonly referred to as software
Software is essential to a computer because without software, a computer can do nothing
Software are created by individuals known as programmers or software developers
A programmer is a person with the training and skills necessary to create programs
Smart Computing Department 4
Computer Systems
❑ Allcomputer system consist of similar hardware devices and software
components
❑ Hardware
It refers to the physical components of a computer
A computer is not an individual device but a system of devices
A computer system consists of the following major components:
The central processing unit (CPU)
Main memory (random-access memory, or RAM)
Secondary storage devices (hard-disk drive)
Input devices
Output devices
Smart Computing Department 5
Hardware
Smart Computing Department 6
Hardware (Contd…)
❑ The CPU
When a computer is performing the tasks, we say that the computer is executing
the program
The CPU is the part of a computer that actually runs programs
Without CPU the computer could not run software
Today’s CPUs, known as microprocessors
The CPU’s job is:
To fetch instructions, follow the instructions
Produce some result
CPU consists of two parts
ALU and control unit
Smart Computing Department 7
Hardware (Contd…)
❑ The CPU
Control unit
It coordinates all of the computer’s operations
Responsible for determining where to get the next instruction
Arithmetic and logic unit (ALU)
It performs mathematical operations
❑ Main Memory
Commonly known as RAM
Volatile type of memory only used for temporary storage while a program
running
CPU is able to quickly access data stored at any random location in RAM
Smart Computing Department 8
Hardware (Contd…)
❑ A computer’s memory is divided into tiny storage cells known as
bytes
One byte is enough memory to store just a single letter or a small number
Each byte is divided into eight smaller storage locations known as bits
The term bit stands for binary digit
Each byte is assigned a unique number known as an address
A bye is identified by its address
E.g., the number 149 is stored in the cell at address 16, and the number 75 at address 23
Smart Computing Department 9
Hardware (Contd…)
❑ Secondary storage
Type of memory that can hold data for long period of times even when there is
no power to the computer
Frequently used programs are stored in secondary memory and loaded into main memory
as needed
The most common types are:
A disk drive
External disk drives
USB (universal serial bus) flash drives
Optical devices
CD (compact disc)
DVD (digital versatile disc)
Smart Computing Department 10
Hardware (Contd…)
❑ Input devices
The device that collects the information and sends it to the computer
Common input devices are:
Keyboard and Mouse
Touch screen
Scanner
Digital camera
Microphone
❑ Output devices
Any information the computer sends to the outside world
Common output devices are: printer, monitor, speakers, etc.
Smart Computing Department 11
Software
❑ The “Software” is a generic term used to describe computer programs
❑ There are two general categories of software
System software
Application software
❑ System software
The program that control and manage the basic operations of a computer
System software is responsible for managing hardware components
Example:
Operating system (OS)
Utility programs (e.g., virus scanners, file-compression program, data-backup programs
Software development tools (e.g., compilers, text editors, IDEs)
Smart Computing Department 12
Software (Contd…)
❑ Application software
Program that make a computer useful for everyday tasks
Application software can be a single program or a collection of small programs
Application software are often called end-user programs or simply applications
Performs specific tasks for an end-user
It enable the user to complete tasks
Creating documents, databases
Sending emails, doing online research
Designing graphics
Running business
Smart Computing Department 13
Programming Languages
❑ To communicate with computers, programmers/developers need a
language which is called programming language
❑ Programs are created through programming languages to control the
behavior and output of a machine through algorithms
❑ Two categories of programming languages:
Low-level language
It resembles the numeric machine language of the computer
Designed to be directly understandable by a computer
It is machine-dependent language. Entirely comprised of binary, 0’s and 1’s
Machine language is also called as machine code
Programs written in low-level language can run and execute very fast
Processor runs low-level program directly without the need of a compiler or interpreter
Smart Computing Department 14
Programming Languages (Contd…)
❑ High level language
It is more like human language
High-level language are platform independent
Programs written in a high-level language can be executed on different types of machines
A program written in the high-level language is called source code
It is designed for developing software programs and web applications
For a computer to understand and execute a program written in high-level
language, it must be translated into machine language
This translation is done using
either compiler or interpreter
Smart Computing Department 15
Programming Languages (Contd…)
❑ High level language
It is more like human language
High-level language are platform independent
Programs written in a high-level language can be executed on different types of machines
A program written in the high-level language is called source code
It is designed for developing software programs and web applications
❑ For a computer to understand and execute a program written in high-
level language, it must be translated into machine language
This translation is done using either:
compiler or interpreter
Smart Computing Department 16
Programming Languages (Contd…)
❑ Compiler
A compiler is a system software program that transforms high-level source code
written by a programmer in a high-level programming language into a low-level
machine language
This converting process is known as compilation
Before program runtime, the entire source code is checked and converted into
machine code
Generates an error message after examining the entire code
Errors can be found before execution
Errors are shown at the end together
Programming languages like C, C++, C#, Java use compilers
Smart Computing Department 17
Programming Languages (Contd…)
❑ Interpreter
An interpreter is a program that reads source code one statement at a time
Translate the statement into machine language and executes the machine language
statement, then continues with the next statement
An interpreter require a discovered error to be fixed before the program can
continue running
Convert one statement at a time at program runtime
The time it takes to analyze the source code is small, but the overall execution
time is relatively slower than compiler
It continues to translate the program until it encounters the first error
Stops when it encounter an error
Programming languages like Python use interpreter
Smart Computing Department 18
Programming Languages (Contd…)
❑ Concept of language level
Smart Computing Department 19
Programming Languages (Contd…)
❑ Well-known high-level programming languages are:
Smart Computing Department 20
Programming Languages (Contd…)
❑ Source code
The statements written by the programmer are called source code
The file where the source code is saved is called the source file (.cpp extension)
❑ Object code
If the program is free of syntax errors, the compiler stores the translated
machine language instructions, which are called object code
In an object file, the translated machine language instructions are stored
❑ Preprocessor
A preprocessor program reads the source code
It searches for special lines that begin with the # symbol
These lines contains commands, or directives (e.g., #include, #define)
Smart Computing Department 21
Programming Languages (Contd…)
❑ Syntax errors
The syntax errors are illegal uses of:
Key words
Operators
Punctuation
Some other language elements
❑ Library
A prewritten code for performing common operations
❑ Executable code
During translation process, a program called the linker combines the object file
with the necessary library routines
Once the linker has finished with this step, an executable file is created
Smart Computing Department 22
Compilation
❑ The process of translating a C++
source file into an executable
file
The entire process of invoking the
preprocessor, compiler, and linker
can be initiated with a single action
This action is known as the
compilation process or simply
compilation
This process transforms human-
readable source code into an
executable program
Smart Computing Department 23
Compilation (Contd…)
❑ The high level programs
are compiled by the
compiler in four stages
Preprocessing
Compilation
Assembling
Linking
Smart Computing Department 24
Compilation (Contd…)
❑ The following three steps are required to
create and translate a C++ program
A text editor is used to save the C++ program in a
file.
A source code is saved to a source file
The source file is put through a compiler for
translation. If no error, an object file made up of
machine code is created.
The object file is also referred to as a module
The linker combines the object file with other
modules to form an executable file
Smart Computing Department 25
Assignment-1
❑ Differentiate the compiler and interpreter. You must include the
following:
How and why are these two different?
Pros and cons
examples
❑ Describe how the C++ compilation process works.
Note: You can submit either by email or as a hard copy.
Smart Computing Department 26
Next Lecture
Computer Programming Concept
Smart Computing Department 27