Chapter 1
Introduction to Computers, the Internet
and the Web
Acknowledgment
The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
OBJECTIVES
Basic computer concepts
Different types of programming languages
Cpprogramming
og a g language
a guage
History
C Standard Library
Object-oriented Programming
Typical C Program Development Environment
The history
y of the Internet and the World Wide
Web
4
What is a Computer?
Computer
Device capable of performing computations and making logical
decisions (hardware)
Computers process data under the control of sets of instructions called
computer programs (software)
Hardware
Various devices comprising a computer, such as central processing unit
(CPU), memory, motherboard and hard disks as well as peripheral
devices (keyboard, screen, mouse CD-ROM)
Hardware trends Every year or two the following approximately
d bl
double:
Amount of memory in which to execute programs
The processor speed at which computers execute their programs
Software
Programs that run on a computer
Computer Organization
Six logical units in every computer:
Input unit
Obtains information from input devices (keyboard, mouse)
Output unit
Outputs information (to screen, to printer, to control other devices)
Memory unit
Rapid access, low capacity, stores input information
Arithmetic and logic unit (ALU)
Performs arithmetic calculations and logic decisions
Central processing unit (CPU)
Supervises and coordinates the other sections of the computer
ALU is now a fundamental building block of the CPU
Secondary storage unit
Cheap, long-term, high-capacity storage
Stores inactive programs
5
Hardware
Evolution of Operating Systems
Batch processing
Do only one job or task at a time
Operating
Ope at g systems
syste s
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
6
Operating Systems
Macintosh
Personal Computing, Distributed Computing, and
Client/Server Computing
Personal computers
Economical enough g for individual
Distributed computing
Computing distributed over networks
Client/server computing
Sharing of information across computer networks between
file servers and clients (personal computers)
7
Personal Computing, Distributed Computing, and
Client/Server Computing
Machine Languages, Assembly Languages, and High-
level Languages
Three types of programming languages
1. Machine languages
g g
Strings of numbers giving machine specific instructions
Example: +1300042774
2. Assembly languages
English-like abbreviations representing elementary computer
operations (translated via assemblers)
Example: LOAD BASEPAY
3. High-level languages
Codes similar to everyday English
Use mathematical notations (translated via compilers)
Example: grossPay = basePay + overTimePay
8
Fortran, COBOL, Pascal and Ada
FORTRAN
Developed by IBM Corporation in the 1950s
Used for scientific and engineering applications that require
p mathematical computations
complex p
COBOL
Developed in 1959 by computer manufacturers, the government and
industrial computer users
Used for commercial applications that require precise and efficient
manipulation of large amounts of data Pascal
Pascal
Developed by Professor Niklaus Wirth in 1971
Designed for teaching structured programming
Ada
Developed under the sponsorship of the U.S. Department of Defense
(DOD) during the 1970s and early 1980s
Able to perform multitasking
History of C
C
Evolved by Ritchie from two previous programming
languages, BCPL and B
Used to develop UNIX
Used to write modern operating systems
Hardware independent (portable)
By late 1970's C had evolved to “Traditional C”
Standardization
Many slight variations of C existed, and were incompatible
Committee formed to create a "unambiguous, machine-
independent" definition
Standard created in 1989, updated in 1999
9
C Standard Library
C programs consist of pieces/modules called functions
A programmer can create his own functions
Advantage:
g the programmer
p g knows exactlyy 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
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,
understandable better organized,
organized and easier to
maintain than procedural programming
Favor modularity
10
C++
C++
Superset of C developed by Bjarne Stroustrup at Bell Labs
"Spruces
Sp uces up"
up C, and
a d provides
p ov des object-oriented
object o e ted capabilities
capab t es
Object-oriented design very powerful
10 to 100 fold increase in productivity
Dominant language in industry and academia
Learning C++
Because C++ includes C, some feel it is best to master C,
then learn C++
More details of C++, see Chapter 18-27 of the textbook
Java
Java is used to
Create Web pages with dynamic and interactive content
Develop
eve op large-scale
a ge sca e enterprise
e te p se applications
app cat o s
Enhance the functionality of Web servers
Provide applications for consumer devices (such as cell
phones, pagers and personal digital assistants)
Java How to Program
Closely followed the development of Java by Sun
Teaches first-year programming students the essentials of
graphics, images, animation, audio, video, database,
networking, multithreading and collaborative computing
11
BASIC, Visual Basic, Visual C++, Visual C# and .NET
BASIC
Developed in the mid-1960s by Professors John Kemeny
and Thomas Kurtz of Dartmouth College as a language for
writing simple programs
Visual Basic
Introduced by Microsoft in 1991 to simplify the process of
making Windows applications
Visual Basic, Visual C++, and Visual C#
Designed for Microsoft’s .NET programming platform
A Typical C Program Development Environment
Phases of C Programs:
Edit (
(C pprogram
g file names
should end with the .c
extension)
Preprocess
Compile
Link
Load
Execute
E t
12
A Typical C Program Development Environment
Phase 1: Create your program with an editor program
Phase 2: A preprocessor find some preprocessor directives
(#include <stdio.h>) to include other files and perform various
text replacements
Phase 3: Compiler compiles the program into machine
languages (object code != object-oriented programming).
Phase 4: A linker links the object code with the code in library
or other places to produce an executable image.
Phase 5: A loader loads the executable image into memory
(RAM).
Phase 6: CPU executes the program one instruction at a time.
The load process in Windows OS is just input the name of the
executable file (for example, lab01.exe).
History of the Internet
The Internet enables
Quick and easy communication via e-mail
International
te at o a networking
etwo g of
o computers
co pute s
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
13
History of the World Wide Web (WWW)
World Wide Web
Locate and view multimedia-based documents on almost
any subject
Makes information instantly and conveniently accessible
worldwide
Possible for individuals and small businesses to get
worldwide exposure
Changing the way business is done
VIP in Computing
Alan Turing: a British mathematician who is the
father of theoretical computer science and artificial
i t lli
intelligence.
The Turing Award is given annually by
the Association for Computing Machinery (ACM)
to "an individual selected for contributions of a
technical nature made to the computing
community. The contributions should be of lasting
and major technical importance to the computer
field". Often recognized as the “Nobel
field Nobel Prize of
computing”. As of 2007, the award is
accompanied by a prize of $250,000, co-
sponsored by Intel and Google.
14
VIP in Communication
Claude E. Shannon is famous for having
founded information theory with one
l d
landmark
k paper published
bli h d iin 1948 “A
Mathematical Theory of Communication”.
Computer Organization
Hardware: Input/Output; RAM (Random-access memory);
Hard disk (secondary storage unit); ALU/CPU; Motherboard;
Computer Case (power); CD or DVD-ROM (peripheral
components).
Moore’ Law: the same price for the double of computing
power approximately every one or two years
Software: Operating systems (OS); Application Software. (A
hierarchical structure)
OS managesg and coordinates activities and the sharingg of the
limited resources of the computer. Applications use
application programming interface (API) provided by
libraries and OS to handle computer resources.
15
Languages
Machine languages (a numerical representation
+1300042774) are hardware or platform dependent. They
are understood directly by ALU/CPU and thus efficient to
computers Every CPU model has its own machine code,
computers. code
or instruction sets.
Assembly languages (a symbolic representation LOAD
BASEPAY) are also architecture dependent. It is difficult to
portable to other systems or machines. Today, it is used
primarily for direct hardware manipulation. Typical uses
are device drivers, low-level embedded systems, and real-
ti systems.
time t
High-level languages like C are more potable to other
platforms and easy to understand by programmers in an
everyday English format (grossPay = basePay +
overTimePay).
C
C standard library contains of modules called functions
(building-block approach). We do not need to re-invent the
wheel and can directly use functions in library. The first part is
to learn how to write C programs,
programs and the second part is to
learn how to use functions in C standard library.
Object-oriented programming (C++ or Java) focuses on
objects (nouns) rather than actions (verbs) (C or Pascal). Its
basic entity is called class. The reusability has been greatly
enhanced, which is beneficial for large software projects.
C Programs typically go through six phases to be executed:
edit, preprocess, compile, link, load and execute.
Integrated Developing Environment (IDE) such as Microsoft
Visual C++ 2005 Express Edition Software provides edit,
preprocess, compile and link in an integrated environment.
16
Web Resources for Self-learning
Google: http://www.google.com/
Wikipedia: http://en.wikipedia.org/wiki/Main_Page
C pprogramming:
og a g: http://www.cprogramming.com/
ttp://www.cp og a g.co /
….
Chapter 2
Introduction to C Programming
The C language facilitates a structured and disciplined
approach to computer program design
design.
Acknowledgment
The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
17