Upload
forkenstein
View
224
Download
0
Embed Size (px)
Citation preview
7/25/2019 COMPUTER MIDTERMS REVIWER.docx
1/12
1
WHAT IS A COMPUTER?
An electronic device operating under the
control of instructions stored in its own
memory that accepts data, processes data
into information and produces and produces
and stores results.
Computer is a programmable machine
designed to follow instructions.
COMPONENTS OF COMPUTER SYSTEMS
Hardware
Software
Peopleware
Dataware
Hardware
The Nuts and Bolts of the Machine
It refers to the physial o!po"e"ts of
the o!p#ter syste!$
Main Hardware Component Categories
1$ I"p#t De%ies
&$ Ce"tral Proessi"' U"it (CPU)
*$ Mai" Me!ory
+$ Seo"dary Stora'e
,$ O#tp#t De%ies
INPUT DE-ICES
Used to se"d i"for!atio" to the
o!p#ter fro! o#tside
Ma"y de%ies a" pro%ide i"p#t
.ey/oard0 !o#se0 sa""er0 di'ital
a!era0 !iropho"e
CENTR2 PROCESSIN3 UNIT (CPU)
The CPU is where !ost al#latio"s ta.e
plae$
It is the 4/rai" a"d heart5 of theo!p#ter syste!$
CPU is ho#sed i" a si"'le hip alled a
microprocessor.
COMPONENTS OF CPU
Control Unit 6 it ats as a s#per%isor
that o"trols a"d s#per%ises the
operatio" i" the CPU$
Arithmetic Logic Unit (ALU) 6 it
perfor!s the !athe!atial a"d lo'ial
operatio"s of the o!p#ter syste!$
MIN MEMORY
Itis a te!porary holdi"' plae for data
a"d i"str#tio"s$ Holds /oth pro'ra!
i"str#tio"s a"d data$
lso alled Ra"do! ess Me!ory
(RM)
Bit
S!allest piee of !e!ory
Sta"ds for bi"ary di'it
Has %al#es 7 (o80 false) or 1 (o"0
tr#e)
Byte
Is 9 o"se#ti%e /its
:ytes ha%e addresses
/yte a" hold o"e harater
SECONDRY STOR3E
Refers to the !edia o" whih data0
i"str#tio"s0 a"d i"for!atio" are .ept$
Seo"dary de%ies a" store i"str#tio"s
a"d data whe" they are "ot /ei"' #sed/y the syste! #"it$
Secondary Storage di8ers fro!
!e!ory0 that it a" hold i"str#tio"s or
ite!s per!a"e"tly$
Main Memory0 /y o"trast0 holds ite!s
o"ly te!porarily while the proessor
i"terprets a"d e;e#tes i"str#tio"s$
OUPUT DE-ICES
Used to se"d i"for!atio" fro! the
o!p#ter to the o#tside
Ma"y de%ies a" /e #sed for o#tp#t
7/25/2019 COMPUTER MIDTERMS REVIWER.docx
2/12
InputDevice
OutputDevice
SecondaryStorageDevices
Centra
ProcessingUnitMain
Me!ory
&
!o"itor0 pri"ter0 spea.er
Main Hardware Component Categories
Software
Bringing the Machine to Life
It refers to the i"str#tio"s or pro'ra!s
that tell the o!p#ter to do a spei
7/25/2019 COMPUTER MIDTERMS REVIWER.docx
3/12
*
Pro'ra!!i"' 2a"'#a'e > e"a/le the
pro'ra!!ers to o!!#"iate with
the o!p#ter$
Pop#lar la"'#a'es@ CAA0 -is#al
:asi0 C0 Ba%a0 PHP
!ypes of rogrammingLang#ages
Mahi"e 2a"'#a'es
sse!/ly 2a"'#a'es
Hi'h>le%el 2a"'#a'es
MACH34$ LA45UA5$S
Mahi"e la"'#a'e 6 or low le%el la"'#a'e is
the !ost /asi la"'#a'e of a o!p#ter$
se#e"e of 7s a"d 1s$
Mahi"e la"'#a'es are the o"ly way to
o!!#"iate diretly with the o!p#ter$
Pro'ra!!i"' i" !ahi"e la"'#a'e are
tedio#s a"d error>pro"e a"d re#ireshi'hly trai"ed pro'ra!!ers$
E;a!ple@ 77171 17771 17777
ASS$MBL LA45UA5$S
sse!/ly la"'#a'es were de%eloped to
!a.e the pro'ra!!ers =o/ easier$
It is a low>le%el pro'ra!!i"' la"'#a'e
for o!p#ters0 !iroproessors0
!iroo"trollers0 a"d other
pro'ra!!a/le de%ies$
I" asse!/ly la"'#a'e0 a" i"str#tio" is
a" easy>to>re!e!/er for! alled
!"e!o"is$
Assembler> a pro'ra! whih tra"slates
the !"e!o"i la"'#a'e #"derstood
/y the pro'ra!!er i"to a /i"ary for!
#"derstood /y the o!p#ter$
E;a!ple@ :;0 ; (re'isters)
H35H6L$0$L LA45UA5$S
Hi'h>le%el la"'#a'es allows the
pro'ra!!er to #se E"'lish>li.e
i"str#tio"s$
Closer to spo.e" la"'#a'es a"d it !a.e
pro'ra!!i"' easier$
Compilers> tra"slate hi'h>le%el
i"str#tio"s i"to 7s a"d 1s or !ahi"e
la"'#a'e$
E;a!ple@ CAA0 C0 Ba%a0 PHP0 -is#al :asi
rocessing a High6Le1el
Lang#age rogram
Editi"' the pro'ra!
Co!pili"'
2i".i"'
E;e#ti"'
$-3!345
Yo# write a pro'ra! with words or
sy!/ols that are #"dersta"da/le to
h#!a" /ei"'s$
Yo# type the pro'ra! diretly i"to a
wi"dow or sree" a"d sa%e the res#lti"'
te;t as a separate
7/25/2019 COMPUTER MIDTERMS REVIWER.docx
4/12
+
This proess prod#es a" i"ter!ediate
o/=et spei/y>step
i"str#tio"s that direts the o!p#ter
what yo# wa"t it to do$
Pro'ra!s are writte" i" a pro'ra!!i"'
la"'#a'e > whih is a set of r#les that
pro%ides a way of telli"' the o!p#terwhat operatio"s to perfor!$
The perso" who reates o!p#ter
pro'ra! is alled o!p#ter pro'ra!!er$
S!$S 34 "5"AMM345
U"dersta"d the pro/le!
Pla" the lo'i
Code the pro'ra!
Co!pile the pro'ra! i"to !ahi"e
la"'#a'e
Test the pro'ra!
P#t the pro'ra! i"to prod#tio"
9. Understand the roblem
:efore writi"' the pro'ra! the
pro'ra!!er !#st
7/25/2019 COMPUTER MIDTERMS REVIWER.docx
5/12
,
the o"ly la"'#a'e
a o!p#ter ."ows$
Its o"sists of 7?s a"d 1?s$
Co!piler is a speial pro'ra! that
tra"slates hi'h>le%el la"'#a'e
i"str#tio"s i"to !ahi"e la"'#a'e$
Co!piler athes all sy"ta; errors$
=. !est the rogram
To e;e#te a"d the" r#" the pro'ra!$
The pro'ra! #po" e;e#tio" is /ei"'
s#/=eted to di8ere"t .i"ds of test data
to a"tiipate a"d orret errors that
!i'ht o#r /efore releasi"' the
pro'ra! to the #sers$
>. #t the rogram into rod#ction
The or'a"iatio" a" "ow #se the
pro'ra!$
Trai"i"' perso""el to #se the pro'ra!$
R#""i"' the pro'ra! #si"' the at#al
data$
Test for #ser?s appro%al$
AL5"3!HM
se#e"e of well>#"derstood steps for
a perso" to follow i" order to ao!plish
a ertai" tas. or to sol%e a parti#lar
pro/le!$
It is a
7/25/2019 COMPUTER MIDTERMS REVIWER.docx
6/12
TerminalblockInput/utput
block
!rocesssymbol
"ecision
symbol
n#pageConnector
ff#pageConnector
Initiali$ation
symbol
%lowlines
S$U-C-$
*L+CHA"!S
'raphial represe"tatio" of the lo'ial
steps that sol%es a pro/le!$
dia'ra! represe"ti"' the lo'ial
se#e"e i" whih a o!/i"atio" of
steps or operatio" is to /e perfor!ed$ It
is a /l#epri"t of the pro'ra!$
Pro'ra!!ers #se Jowharts to
#"dersta"d the lo'i proessi"' of data$
ltho#'h ti!e o"s#!i"'0 it?s the /est
tool for /e'i""ers$
BAS3C *L+CHA"!345 SMBLS
!erminal (0AL)
6 #sed to si'"ify the /e'i""i"' a"d e"d of
Jowhart
3nitiali?ation (H$8A54)
> si'"i perfor!s a"y al#latio"s that are to /e
do"e$
-ecision (-3AM4-)
> si'"i show the e"try or e;it poi"t of theJowhart$ "o">proessi"' sy!/ol #sed to
o""et o"e part of a Jowhart to a"other
witho#t drawi"' a Jowli"es$
@6page Connector ($4!A54)
> So!eti!es a Jowhart will "ot
7/25/2019 COMPUTER MIDTERMS REVIWER.docx
7/12
K
4ames cannot contain spaces.
4ames cannot contain special
characters
"elational perators a" operators that
o!pares two %al#es a"d deter!i"es therelatio"ship /etwee" the!$
*o#r *lowchart Str#ct#res
Se#ence '-ecision '"epetition'
Case
S$U$4C$ S!"UC!U"$
Direts the o!p#ter to proess the
pro'ra! i"str#tio"s0 o"e after a"other0
i" the order listed i" the pro'ra!$
Series of atio"s are perfor!ed i"
se#e"e
-$C3S34 S!"UC!U"$
Ma.es a deisio" a"d the" ta.es a"
appropriate atio" /ased o" that
deisio"
E;a!ple@ waiti"' or rossi"' at railroad
tra.s depe"di"' o" si'"al li'hts
"$$!3!34 S!"UC!U"$
repetitio" str#t#re represe"ts part of
the pro'ra! that repeats$ This type of
str#t#re is o!!o"ly ."ow" as a loop$
CAS$ S!"UC!U"$
O"e of se%eral possi/le atio"s is ta.e"0
depe"di"' o" the o"te"ts of a %aria/le$
se#docode
detailed desriptio" of what a
o!p#ter pro'ra! or al'orith! !#st do$
te;t#al prese"tatio" of a Jowhart
Close to a "at#ral la"'#a'e
The o"trol str#t#res i!pose the
lo'i
May /eo!e a part of the pro'ra!
do#!e"tatio"
+here did C// come fromD
Deri%ed fro! the C la"'#a'e
C was deri%ed fro! the :
la"'#a'e
: was deri%ed fro! the :CP2
la"'#a'e
:CP2 > :asi Co!/i"ed
Pro'ra!!i"' 2a"'#a'e
+hy the E//FD
AA is a" operator i" CAA
C de%eloped /y De""is Rithie at TLT
:ell 2a/s i" the 1K7s$
Used to !ai"tai" UNI syste!s
Ma"y o!!erial appliatio"swritte" i" C
CAA de%eloped /y :=ar"e Stro#str#p at
TLT :ell 2a/s i" the 197s$
O%era!e se%eral shorto!i"'s
of C
I"orporated o/=et orie"ted
pro'ra!!i"'
C re!ai"s a s#/set of CAA
-e1eloping a program in C// re#ires at
least fo#r steps&
7/25/2019 COMPUTER MIDTERMS REVIWER.docx
8/12
9
$diting the program6Yo# write a
pro'ra! with words or sy!/ols that are
#"dersta"da/le to h#!a" /ei"'s$
- Yo# type the pro'ra! diretly i"to a
wi"dow or sree" a"d sa%e the res#lti"'
te;t as a separate
speifeat#red I"te'rated
De%elop!e"t E"%iro"!e"t (IDE) > whih is a/le
to reate i"dows or DOS>/ased CAA
pro'ra!s #si"' the Cy'wi" o!piler$
3-$ 6 a syste! that i"l#des /oth editor a"d a
o!piler$
Mirosoft -is#al CAA0 :orla"d CAA are other
e;a!ple of IDE
Steps in Con,g#ring a -e16C// rogram
M$M" LCA!34
-ata !ype > i"diates what type of i"for!atio"
the address will store (e$'$0 "#!eri or te;t#al)$
3denti,er> allows the pro'ra!!er to refer to
the !e!ory loatio" elsewhere i" the pro'ra!$
> Na!es !ade #p /y the pro'ra!!er$
!ypes of 3denti,er
0ariables 6 are !e!ory loatio"s
whose %al#es a" ha"'e d#ri"' r#"ti!e
(whe" the pro'ra! is r#""i"')$ Most
!e!ory loatio"s are %aria/les$
Constants > are !e!ory loatio"s
whose o"te"t a""ot /e ha"'ed
d#ri"' pro'ra! e;e#tio"$ Ofte" "a!edi" #pperase letters$ E;a!ple@ PI
(o"sta"t)0 radi#s (%aria/le)
"#les 3n 4aming 3denti,ers (1ariables)
1alid or in1alid 1ariables
7/25/2019 COMPUTER MIDTERMS REVIWER.docx
9/12
C// 7eywords
7eywordsare prede stores :oolea" %al#es (tr#e or
1 a"d false or 7)
short a"d int >store i"te'ers
("#!/ers witho#t a dei!al plae)
- Di8ere"es are ra"'e of %al#es a"d
!e!ory #sed (inthas the 'reater of/oth) oat a"d do#ble 6 store real
"#!/ers ("#!/ers with a dei!al
plae)
- Di8ere"es are ra"'e of
%al#es0 preisio"0 a"d !e!ory
#sed (do#blehas the 'reater
of eah)
char> stores haraters (letter0
sy!/ol0 or "#!/er that will "ot
/e #sed i" a al#latio")
- O"ly o"e harater stored at a
ti!e
string 6 is a #ser>de
7/25/2019 COMPUTER MIDTERMS REVIWER.docx
10/12
17
co#t (see6o#t) console o#tp#t> se"d
i"for!atio" 4o#t5 to the #ser or o#tp#t to
the !o"itor
- Pair with the i"sertio" operator (JJ)
> to display i"for!atio" o" the
o!p#ter sree"
Starting a 4ew Line
endl (e"d li"e)6 is a strea!
!a"ip#lator that ad%a"es the #rsor
to the "e;t li"e o" the sree"
co#tJJ KHello' thereK JJ endlI
n 6 (sa!e as endl) a#ses a "ew
li"e to /e started o" the !o"itor
co#tJJ KHello' there nKI
:oth are e#i%ale"t to pressi"' the
E"ter .ey
rogram Statement
o#t QI"p#t the #sed to
o/tai" i"for!atio" fro! the .ey/oard
(pro'ra! pa#ses while #ser e"ters data)
- Pair with e;tratio" operator (NN) >
ta.es i"for!atio" fro! the .ey/oard
to a %aria/le a"d stores it i" i"ter"al
!e!ory
rogram Layo#t
Co!piler aepts al!ost a"y patter"
of li"e
/rea.s a"d i"de"tatio"
Pro'ra!!ers for!at pro'ra!s so
theyare easy to read
7/25/2019 COMPUTER MIDTERMS REVIWER.docx
11/12
11
Plae ope"i"' /rae a"d
losi"' /rae ?
o" a li"e /y the!sel%es
I"de"t state!e"ts
Use o"ly o"e state!e"t per
li"e
-aria/les are delared /efore they
are #sed
Typially %aria/les are delared
at the /e'i""i"' of the
pro'ra!
State!e"ts ("ot always li"es)
e"d with a se!i>olo"
system (Kpa#seK)I
- pa#ses pro'ra! e;e#tio" a"d
display Press a"y .ey to o"ti"#e
!essa'e i" the o!!a"d pro!pt
wi"dow o" the o!p#ter sree" ret#rn OI
- ret#r"s the "#!/er 7 to the
operati"' syste! to i"diate
that the pro'ra! e"ded
"or!ally
Comment
is si!ply a !essa'e to the
perso" readi"' that pro'ra!
a"d is referred to as i"ter"al
do#!e"tatio"
:e'i" with (two forward
slashes) /efore the te;t yo#
wa"t treated as a o!!e"t
thro#'h the e"d of the li"e$
E;@ !his is a sample C//program.
Comment
Co!!e"ts a" spa" !#ltiple
li"es
:e'i" with Pa"d e"d with P
E;@
P6666666666666666666666666666
M#lti6line C// style comment
6666666666666666666666666666P
Pro'ra! o!!e"ts !ay /e
#sed a"ywhere i" the pro'ra!0
a"d are i'"ored /y the
o!piler$
Layo#t of a C// rogram
7/25/2019 COMPUTER MIDTERMS REVIWER.docx
12/12
1&
Special Characters in C//
:#'> !ista.e i" a pro'ra!
De/#''i"'> Eli!i"ati"' !ista.es i"
pro'ra!s
!wo !ypes of rogram $rrors
Sy"ta; Errors
-
-iolatio" of the 'ra!!ar r#les of thela"'#a'e- Diso%ered /y the o!piler- Error !essa'es !ay "ot always show
orret loatio" of
errors
2o'i Errors
>Errors i" the pro'ra!?s al'orith!
>Most di#lt to dia'"ose
> Co!piler does "ot reo'"ie a" error