Fundamentals of Computer Programming: Muhammad Qaisar Choudhary
Fundamentals of Computer Programming: Muhammad Qaisar Choudhary
Fundamentals of Computer Programming: Muhammad Qaisar Choudhary
Programming
Lecture 1
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1
Agenda
Outline
1. What Is a Computer?
2. Computer Organization
3. Evolution of Operating Systems
4. Personal Computing, Distributed Computing and Client/Server
Computing
5. Machine Languages, Assembly Languages and High-level Languages
6. The C Standard Library
7. The Key Software Trend: Object Technology
8. Structured Programming
9. The Basics of a typical C Program Development Environment
10. Hardware Trends
11. History of the Internet
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
2
What is a Computer?
• Computer
– Device capable of performing computations and
making logical decisions
– Computers process data under the control of sets of
instructions called computer programs
• Hardware
– Various devices comprising a computer
– Keyboard, screen, mouse, disks, memory, CD-ROM,
and processing units
• Software
– Programs that run on a computer
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
3
Computer Organization
• Six logical units in every computer:
1. Input unit
• Obtains information from input devices (keyboard, mouse)
2. Output unit
• Outputs information (to screen, to printer, to control other
devices)
3. Memory unit
• Rapid access, low capacity, stores input information
4. Arithmetic and logic unit (ALU)
• Performs arithmetic calculations and logic decisions
5. Central processing unit (CPU)
• Supervises and coordinates the other sections of the computer
6. Secondary storage unit
• Cheap, long-term, high-capacity storage
• Stores inactive programs
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
4
Evolution of Operating Systems
• Batch processing
– Do only one job or task at a time
• Operating systems
– Manage transitions between jobs
– Increased throughput
• Amount of work computers process
• Multiprogramming
– Computer resources are shared by many jobs or tasks
• Timesharing
– Computer runs a small portion of one user’s job then
moves on to service the next user
• Multi core Systems
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
5
Personal Computing, Distributed
Computing, and Client/Server
Computing
• Personal computing
– Economical enough for individual
• Distributed computing
– Computing distributed over networks
• Client/server computing
– Sharing of information across computer networks
between file servers and clients (personal
computers)
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
6
Machine Languages, Assembly
Languages, and High1a-level
Languages
Three types of programming languages
1. Machine languages
• Strings of numbers giving machine specific instructions
• Example:
+1300042774
+1400593419
+1200274027
2. Assembly languages
• English-like abbreviations representing elementary
computer operations (translated via assemblers)
• Example:
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
7
Machine Languages, Assembly
Languages, and High-level Languages
Three types of programming languages
(continued)
3. High-level languages
• Codes similar to everyday English
• Use mathematical notations (translated via compilers)
• Example:
grossPay = basePay + overTimePay
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
8
The C Standard Library
• C programs consist of pieces/modules called
functions
– A programmer can create his own functions
• Advantage: the programmer knows exactly how it works
• Disadvantage: time consuming
– Programmers will often use the C library functions
• Use these as building blocks
– Avoid re-inventing the wheel
• If a premade function exists, generally best to use it rather
than write your own
• Library functions carefully written, efficient, and portable
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
9
The Key Software Trend: Object
Technology
• Objects
– Reusable software components that model items in
the real world
– Meaningful software units
• Date objects, time objects, paycheck objects, invoice objects,
audio objects, video objects, file objects, record objects, etc.
• Any noun can be represented as an object
– Very reusable
– More understandable, better organized, and easier to
maintain than procedural programming
– Favor modularity
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
10
Structured Programming
• Structured programming
– Disciplined approach to writing programs
– Clear, easy to test and debug and easy to modify
• Multitasking
– Specifying that many activities run in parallel
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
11
Basics of a Typical C Program
•
Development
Phases of C Programs:
Environment Program is created in
the editor and stored
Editor Dis on disk.
k
Preprocessor program
1. Edit Preprocessor Dis processes the code.
k
Compiler creates
2. Preprocess Compiler Dis object code and stores
k it on disk.
3. Compile Linker Dis Linker links the object
code with the libraries
Primary k
Memory
4. Link Loader
Loader puts program
5. Load Disk ..
in memory.
..
..
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
13
History of the Internet
• The Internet enables
– Quick and easy communication via e-mail
– International networking of computers
• Packet switching
– The transfer of digital data via small packets
– Allows multiple users to send and receive data simultaneously
• No centralized control
– If one part of the Internet fails, other parts can still operate
• TCP/IP
• Bandwidth
– Information carrying capacity of communications lines
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
14