Programming Fundamentals: Lecture # 1
Programming Fundamentals: Lecture # 1
Lecture # 1
1
Acknowledgment
• This is to acknowledge that Lecture Handouts and Video
Lectures of course “Introduction to Programming” by Dr.
Naveed A. Malik, Virtual University of Pakistan will be used
as learning material for this course of “Programming
Fundamentals”.
2
Course Outline
• Detailed Course Outline and Lecture Plan is given in
the Course Specification File.
• Please have a look on this file available in LMS
(Google Classroom)
• All Lectures along with Text Books and other
Reading Material will also be available through LMS
(Google Classroom).
Dr Shafiq 3
Teaching Methodology
Dr Shafiq 4
Objectives
• To introduce basic tools and techniques of Programming
5
Introduction to Computers
Dr Shafiq 6
Introduction to Computers
• A computer system is composed of hardware and
software
• Hardware components are the physical, tangible
pieces that we can see and touch.
• Software is a set of programs designed to perform a
specific task.
• This course is concerned with the software.
Dr Shafiq 7
Introduction to Computers
• Program
– a sequence of instructions to accomplish a result
– a computer processes information under the
direction of a program
• Data
– information to be processed by a program
• Example
– Data: for each employee, the employee number,
hours worked & hourly pay rate
– Program: instructions on how to process the data
to produce pay cheques, payroll register, etc.
Dr Shafiq 8
Introduction to Computers
• Computer software is …
– The collection of programs used by a computer
which includes:
Editors
Translators
System Managers
Dr Shafiq 9
Computer Organization
Five main components
• Input devices
– Allows communication to the computer
• Output devices
– Allows communication to the user
• Processor (CPU)
• Main memory
– Memory locations containing the running program
• Secondary memory
– Permanent record of data often on a disk
Dr Shafiq 10
Computer Organization
Dr Shafiq 11
The Central Processing Unit
fetch
execute decode
Dr Shafiq 12
The Central Processing Unit
add
subtract
multiply
divide
move data from location to location
Dr Shafiq 13
Computer Memory
• Main Memory
– Long list of memory locations
• Each contains zeros and ones
• Can change during program execution
– Binary Digit or Bit
• A digit that can only be zero or one
– Byte
• Each memory location has eight bits
– Address
• Number that identifies a memory location
Dr Shafiq 14
Larger Data Items
• Some data is too large for a single byte
– Most integers and real numbers are too large
Dr Shafiq 15
Larger Data Items
Dr Shafiq 16
Secondary Memory
• Main memory stores instructions and
data while a program is running.
• Secondary memory
– Stores instructions and data between sessions
– A file stores data or instructions in
secondary memory
Dr Shafiq 17
Secondary Memory Media
• A computer might have any of these
types of secondary memory
– Hard disk
• Fast
• Fixed in the computer and not normally removed
– Floppy disk
• Slow
• Easily shared with other computers
– Compact disk
• Slower than hard disks
• Easily shared with other computers
• Can be read only or re-writable
Dr Shafiq 18
Memory Access
• Random Access
– Usually called RAM
• Computer can directly access any memory location
• Sequential Access
– Data is generally found by searching through
other items first
• More common in secondary memory
Dr Shafiq 19
Computer Software
• Firmware
– Device drivers, BIOS
• Operating Systems
– Windows, Mac, Linux etc
• Applications
– Word, Excel, games, music players etc
• Programing Languages
– C, C++, Java, C# etc
Dr Shafiq 20
Computer Input
• Computer input consists of
– A program
– Some data
Dr Shafiq 21
Computer Input
Dr Shafiq 22
Programing Languages
• Machine Language
– The language a computer can understand directly
• Assembly Language
– Also called low level language
– Computer cannot understand this language
directly.
– Software needed to convert assembly language
into machine language
– This software is called Assembler.
Dr Shafiq 23
Programing Languages
• High-level Languages
– Examples: C, C++, Java , Pascal , Visual
Basic , FORTRAN, COBOL , Lisp, Ada
– Computer cannot understand these language
directly.
– Software needed to convert these language into
machine language
– This software is called Compiler.
– Resemble human languages
– Are designed to be easy to read and write
Dr Shafiq 24
Compilers
• Translate high-level language to
machine language
– Source code
• the original program in a high level language
– Object code
• the translated version in machine language
Dr Shafiq 25
Compilers
Dr Shafiq 26
Linkers
• Some programs we use are already compiled
– Their object code is available for us to use
– For example: Input and output routines
• A Linker combines
– The object code for the programs we write
and
– The object code for the pre-compiled routines
into
The machine language program the CPU can run
Dr Shafiq 27
Linkers
Dr Shafiq 28
The C Compilation Model
Dr Shafiq 29
History Note
• First programmable computer
– Designed by Charles Babbage
– Began work in 1822
– Not completed in Babbage’s life time
• First programmer
– Ada Augusta, Countess of Lovelace
• Colleague of Babbage
Dr Shafiq 30
Programming and Problem Solving
• Algorithm
– A sequence of precise instructions which
leads to a solution
• Program
– An algorithm expressed in a language the
computer can understand
Dr Shafiq 31
Programing and Problem Solving
Dr Shafiq 32
Program Design
• Programming is a creative process
– No complete set of rules for creating a program
Dr Shafiq 33
Program Design
• Be certain the task is completely specified
– What is the input?
– What information is in the output?
– How is the output organized?
Dr Shafiq 34
Implementation Phase
• Translate the algorithm into a programming
language
– Easier as you gain experience with the language
Dr Shafiq 36
Introduction to C
• C is a general purpose high level programming
language. Because of its flexibility and efficiency
• It is widely used for software development.
• Its allow the development of well-structured
programs.
• The data types and control structures are directly
supported by most computers, resulting in the
construction of efficient programs.
Dr Shafiq 37
Evolution of C Language
• C was developed by Dennis Ritchie at Bell
Laboratories in 1972.
• It was evolved from ALGOL, BCPL(Basic
Combined Programming Language), and B.
• C uses many concepts of these languages and new
features like data types.
• It was then approved by the International standards
Organization (ISO) in 1990. It was updated in 1999.
Dr Shafiq 38
Characteristics of C Language
• C language is well suited for structured modular
programming
• C is smaller which has minimal instruction set and
programs written in C are efficient and fast
• C is highly portable
• C is highly flexible
Dr Shafiq 39
Questions
Any Question Please?
40
Further Readings
• C How to Program by Dietel, Chapter 1.
41
Thanks
42