Topics
1.
2.
3.
4.
5.
Overview of PC components
Programming languages
C programming language
C programming environment
C program at a glance
BS (May 2012)
Topic 1
OVERVIEW OF PC COMPONENTS
BS (May 2012)
Elements of a Computer
3
2
Software
Hardware
Program?
BS (May 2012)
Main Memory
A semiconductor device which stores the
information necessary for a program to run.
Types:
1. ROM (Read Only Memory)
Contains information that is necessary for the
computer to boot up
The information stays there permanently even
when the computer is turned off.
01110111
10110010
10001100
A
1
A
2
A
3
A
4
A
5
A
6
A
7
A
8
A
9
BS (May 2012)
10000110
01110110
10101110
10010001
00001010
10010000
11011100
10110111
01111110
B
1
B
2
B
3
B
4
B
5
B
6
B
7
B
8
B
9
6
CPU
Does most of the work in executing a
program
The CPU inside a PC is usually the
microprocessor
Three main parts:
1. Control Unit
Fetch instructions from main memory and put them
in the instruction register
3. Registers
Temporarily store instructions or data fetched from
memory
BS (May 2012)
BS (May 2012)
Input/Output Devices
Input Devices
Accepts information from the user
and transforms it to digital codes
that the computer can process
Example:
Output Devices
An interface by which the
computer conveys the output to
the user
Example:
BS (May 2012)
Computer Networks
Computers are now linked together in
networks communicate
Types:
1. LAN (
2. WAN (
BS (May 2012)
10
Software
Consists of programs that enable us
to solve problems with a computer
Operating
Systems
Utility
Programs
Language
Translation
System Software
*Complete this list
BS (May 2012)
Application
Software
11
Topic 2
PROGRAMMING LANGUAGES
BS (May 2012)
12
What is Programming?
Programming is instructing a
computer to do something for you
with the help of a programming
language
A programming language contains
instructions for the computer to
perform a specific action or a specific
task:
'Calculate the sum of the numbers from 1 to 10
'Print I like programming
'Output the current time'
BS (May 2012)
13
What is Programming?
Programming Language is different
compared to our everyday-language
(natural language); spoken and
written
Does not have to be 100% but still
understandable
Depends on circumstances; the context
one word can have many meaning
depending on the situation
For example:
OPERATE
BS (May 2012)
14
What is Programming?
The two roles of a programming language:
Technical: It instructs the computer to
perform tasks.
Conceptual: It is a framework within
which we organize our ideas about things
and processes.
In programming, we deal with two kind of
things:
Data - representing 'objects' we want to
manipulate
Procedures -'descriptions' or 'rules' that
define how to manipulate data
BS (May 2012)
15
Programming Language
Programming Language is a Formal
Language used to communicate to a
computer.
Very specific (one word means one thing context free)
since to 'talk' to a computer; to instruct a computer; our
commands must be 100% clear and correct.
Either Functional - tell what to do but not how (sum
[1...10])
or Imperative - describing the step by step to
accomplish the task (Take the first number and add
the next number to it; then add the next number to the
sum; and ; until you have reached 10 as number
to be added. Then print the sum of all numbers)
BS (May 2012)
16
Programming Language
Can be classified into as a special-purpose
and general-purpose programming
languages.
Special-purpose : is design for a particular
type of application
Structured Query Language (SQL)
17
1. Machine Language
The only language that the processor actually
understand.
Consists of binary codes: 0 and 1
Example:
1101 0001 1000 0101 1000 0110 1111 0001
0100 1100 0101 1110 0101 1010 0001 1100
Each of the lines above corresponds to a specific
task to be done by the processor.
Programming in machine code is difficult and slow
since it is difficult to memorize all the
instructions. Mistakes can happen very easily.
Processor dependent (different machine
language for different CPU) - not portable
BS (May 2012)
18
2. Assembly Language
Enable machine code to be represented in words
and numbers.
Example of a program in assembly language:
LOAD A,0111001100
9999
LOAD A, 9999
LOAD B,1000110011
8282
LOAD A, 9999
LOAD B, 8282
Assembler
SUB
B
SUB B
1001111001
MOV C, 1100110010
A
MOV
C,
A
LOAD B, 8282
Cannot be processed directly by a computer,
must be converted to machine language using
assemblers
Easier to understand compared to machine code
but still is quite difficult to use.
Each instruction corresponds to a specific
machine code: lengthy programs.
Processor dependent and not portable.
BS (May 2012)
19
3. High-level Language
BS (May 2012)
20
Topic 3
C PROGRAMMING LANGUAGE
BS (May 2012)
21
What is C?
Why C? - Because based on 'B'; developed at
Bell Laboratories
C was developed by Dennis Ritchie at Bell
Laboratories in 1972.
C combines the power of high-level languages
with the power of assembly languages.
Starts as a system implementation language,
but has evolved into general-purpose language
and available for a wide variety of computers.
C coupled with good program design
techniques - generate well structured, easy
to read and easy to maintain program
BS (May 2012)
22
What is C?
In 1983, the American National
Standards Institute (ANSI) set up
X3J11, a Technical Committee to
draft a proposal for the ANSI
standard, which was approved in
1989 and referred to as the ANSI/ISO
9899 : 1990 or simply the ANSI C,
which is now the global standard for
C.
BS (May 2012)
23
C An Imperative Language
C is a highly imperative language
BS (May 2012)
24
Example of a C program
BS (May 2012)
25
Topic 4
C PROGRAMMING ENVIRONMENT
BS (May 2012)
26
IDE
The system software necessary to develop C
application program are bundled into an
integrated development environment (IDE)
A typical IDE contains text editor, C compiler,
preprocessor, libraries, other tools
Components of C programming environment:
Language features to carry out basic operations
(Ex. Compare data values, arithmetic operation)
Libraries routines to carry out operations not part
of the language (Standard libraries ex. #include
<stdio.h> & programmer-defined libraries)
BS (May 2012)
27
Ms Visual C++
BS (May 2012)
28
Topic 5
C PROGRAM AT A GLANCE
BS (May 2012)
29
A Simple C Program
Outpu
t: VIEW
CONSOLE
of the C
programs
output
BS (May 2012)
30
Summary
PC components
Hardware : main memory, CPU, storage devices,
I/O devices
Software : system software & application software
Programming languages
Machine language, assembly language, high-level
languages
31