Lecture 1 - Introduction
Lecture 1 - Introduction
Programming
CS-112 By Dr. Mir Yasir Umair
Associate Professor, MCS, NUST
• Computers
Computer Systems
o Devices for performing computations at high speeds with great accuracy
o A machine that can be programmed to manipulate symbols. Can perform complex & repetitive procedures quickly,
precisely and reliably. Can quickly store and retrieve large amounts of data.
• Program
o A set of instructions for a computer to follow, written in specific programming language
3
Definitions
• program: A set of instructions that are to be carried out by a computer.
4
Computer Systems
• Hardware (HW)
oActual physical machines (equipment) that make up the
computer
• Software (SW)
oA collection of programs used by a computer
oA set of instructions provided by the programmer that the
computer follows.
oProgram instructions have to be stored in main memory
before they can be executed.
I/O Devices
CPU
Secondary Memory
Main Memory
I/O devices are controlled by drivers, which are very specialized kinds of programs
• Costs
o Hardware costs dropping
o Software development costs rising
• Software development complexity
• Programmer salaries
• Cost of slipping schedules
o Unanticipated interactions in complex systems
o Unpredictability of software development times
Operation Address
• If the computer is not doing what we want, it’s because WE made a mistake.
• Users are not always very intelligent
37
A Simple C++ Program
• Preprocess directives are not
statements (no semi-colon ;)
• Case Sensitive
o Main vs main
38
Listing 1.2
• Output?
39
Listing 1.3
• Output?
40
Output?
41
C++ Program
Development Cycle
42
Programming Style and
Documentation
• Appropriate Comments
• Comment Styles
• Proper Indentation and Spacing
43
Errors?
44
Programming Errors
• Syntax Errors
• Runtime Errors
• Logic Errors
45
Programming Errors
• Syntax Errors
;
46
Programming Errors
• Syntax Errors
• Runtime Errors
47
Programming Errors
• Syntax Errors
• Runtime Errors
• Logic Errors
48
Common Errors
50
. Homework
• Think of 3 tasks you have encountered in your studies that you would
like to write a program for.
• Deadline.. Next class