Computer Programming: Code: C Languange
Computer Programming: Code: C Languange
Programming
Code: C Languange
Week 1
Introduction to Computer
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
3
eureka!
Algorithm:
Algorithm A set of
instructions describing how to
do a task (or process).
Programming: C
Topics
Hardware components
Computer Networks
Transistor
Collector
Base
Emitter
semi-conductor
Transistor
Collector
Base
Emitter
off : 0
7
Transistor
Collector
Base
Emitter
on : 1
8
Transistor
Collector
Base
Emitter
Modern-day chips (about 3 x 3 mm in size) can contain
up to millions of transistors.
9
Gates
Gate: a group of transistors
Types:
AND Gate
OR Gate
NOT Gate
10
A AND B
A AND B
0
0
1
0
1
0
0
0
0
1
A
B
A AND B
11
AND Gate
0
0
1
1
0
1
0
1
OR Gate
A AND B A OR B
0
0
0
1
0
1
1
1
12
NOT Gate
NOT A
0
1
1
0
13
1 1 0 0 1 1 0 1
0 1 1 0 0 1 1 0
A AND B =
0 1 0 0 0 1 0 0
0 or 1
Gates are the basic building blocks of computers.
15
Hardware Components of a
Typical Computer
Input/Output
Devices
Central
Processing
Unit
Memory
16
17
Computer Organization
2. Output unit
3. Memory unit
Hardware Trends
Every year or two the following approximately
double:
Amount of memory in which to execute programs
Amount of secondary storage (such as disk storage)
Used to hold programs and data over the longer term
Processor speeds
The speeds at which computers execute their programs
19
Moores Law
90 nm
596 mm2
1.7 billions
Montecito
10 m
13.5mm2
2,25
0
42million
s
Exponential growth
20
Hardware Components of a
Typical Computer
Input/Output
Devices
Central
Processing
Unit
Memory
Hardware Components of a
Typical Computer
Input/Output
Devices
Central
Processing
Unit
Memory
A bit: 0 or 1
A word: chunk of bits (8, 16, 32 or 64 bits)
a byte = 8 bits
a kilobyte = 210 bytes = 1024 bytes
a megabyte = 1024 KB = 220 bytes
= 1,048,576 bytes
a gigabyte = 1024 MB = 230 bytes
a terabyte = 1024 GB = 240 bytes
23
Hardware Components of a
Typical Computer
Input/Output
Devices
Central
Processing
Unit
Memory
Communications device
Examples: Modems, Ethernet cards
25
Features of Computers
Speed
CPU speed
CPU clock speed: in cycles per second ("hertz")
Examples: 700MHz Pentium III, 500MHz G4
26
Features of Computers
Speed (continued)
In common PC's:
system clock speed can be set in the main board
CPU clock speed is the bus speed times a "multiplier"
Example: A 150MHz CPU may be running at 2.5 x 60MHz, 3
x 50MHz or 2 x 75Mhz ("overclocked" system bus)
27
Features of Computers
Speed (continued)
RAM access speed
about 60ns (1 nanosecond = a billionth of a second), and
getting faster
may be rated with respect to "bus speed" (eg. PC-100)
Cache memory
faster than main memory (about 20ns access speed), but
more expensive
contains only data which the CPU is likely to use next
28
Features of Computers
Speed (continued)
Communications
Examples: modems at about 56 kilobits per second, and network
cards at 10 or 100 megabits per second.
Interface
Examples: ISA, PCI, IDE, SCSI, ATA, USB, etc....
29
Features of Computers
Reliability
Maintenance issues
Operating conditions
Example: heat, ventilation, "over-clocking, power supply
Error detection
Example: parity check, CRC
Modes of communication
Parallel communication:
all the bits are transferred at the same time
each bit on a separate line
Serial communication:
one bit at a time.
31
Modems (MOdulator-DEModulator)
Remote
Computer
Digital
Data
Modem
Audio signal
phone lines
Home
Computer
Digital
Data
Modem
32
Computer Networks
Types
Local Area Networks (LAN)
Computers in an organization.
Example: the PCs in the lab.
33
Computer Networks
Method of communication
Each computer has an address
Example: IP address
34
Computer Networks
Method of communication (continued)
The packets are sent via links from computer to
computer (routing)
Each intermediate computer receives and
retransmits the message (hops)
The packets do not necessarily arrive in the order in which
they were sent.
Summary
36
Week 2
Introduction to Programming
37
Software
Software are programs written to perform
specific tasks.
Two types of programs
System programs - programs that take control of
the computer, such as the operating system (e.g.
Windows, OS/2, Linux, etc.)
Application programs - programs that perform a
specific task. (e.g. Word processors, spreadsheets,
and games are examples of application programs)
38
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 users job then
moves on to service the next user
39
Numeri
Proble
cal
ms
43
Using the assembly language instructions, the equation to calculate the weekly
wages can be written as follows:
LOAD
force
MULT
distance
STOR
work
Assembler: An assembler is a program that translates a program written in 44
assembly language into an equivalent program in machine language.
46
PROGRAMMING
LANGUAGES
BASIC
Visual
Basic
Developed by Microsoft, VB uses a graphical interface to develop eventdriven Windows programs. Visual Basic for Applications (VBA) is a subset of
VB that allows programmers to develop macros in the Microsoft Office
environment.
COBOL
C++
FORTRA
N
Pascal
Java
47
50
52
53
58