..
Introduction to Programming.
Lecture-01
Prepared by: Mr. Hafeez-ur-rahman
Programming?
Programming is used to solve problems on the
computer system.
Programming Language
Language is a system of communication
People use languages to communicate with each
other
To communicate with computer we need
language
To write programs on the computer system we
need programming languages (computer
languages).
Natural Languages vs. Formal
Languages
Natural languages evolve over time by a
community like Urdu, English, Pashto etc.
Formal languages are developed by experts in a
particular field to a solve a particular problem.
Like C, C++, Java, Python etc. (Programming
languages.
Natural Languages vs. Formal
Languages…
Logic is a formal language for dealing with
propositions
Calculus is a formal language for dealing with
numbers
Level of Languages
There are three level of languages:
1. Low level language
Machine Language
2. Middle level language
Assembly Language
3. High level language
Fortran, Cobol, Pascal, C, C++, Java etc.
C++
C++ was developed by Bjarne Stroustrup in 1979
We will use C++ in this course as a programming
language.
C++ is considered as mother of all programming
language, because the syntax of most of the
programming languages are taken from C++.
Constant vs. Variable
Any quantity that does not change is called
constant e.g. DOB, Blood Group, the value of pi etc.
Any quantity that changes is called variable e.g.
Age, speed, velocity, weight, temperature etc.
Variable from programming point of
view
Variable is a name given to a location in memory
where different types of constants is stored.
X
Types of Constants
There are three types of constants:
1. Integer constant
2. Real constant
3. Character constant
Integer Constant
Any numeric value that does not contain a
decimal point is called integer constant.
It can be positive or negative
If no sign is preceded then it will be assumed as
positive.
For example: +56, -2, 1000 etc.
Real Constant
Any numeric value that contains a decimal point
is called integer constant.
It can be positive or negative
If no sign is preceded then it will be assumed as
positive.
For example: 3.4, 56.78, -1.2, +100.3 etc
Character Constant
Any single alphabet or single digit or single
special symbol when enclosed in inverted
commas is called a character constant.
For example: ‘A’, ‘9’, ‘$’, ‘0’ etc.
End