100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Class notes

Elementary Programming

Rating
-
Sold
-
Pages
63
Uploaded on
31-01-2025
Written in
2023/2024

It gives a clear understanding of the basic concepts of programming in object oriented programming languages especially using Java.It gives many examples to help you understand the concepts especially if you are a beginner. With this document you will gain understanding of the basics of programming in OOP. It also provides you with test questions to help you practice coding.

Show more Read less
Institution
Course











Whoops! We can’t load your doc right now. Try again or contact support.

Connected book

Written for

Institution
Course

Document information

Uploaded on
January 31, 2025
Number of pages
63
Written in
2023/2024
Type
Class notes
Professor(s)
Jefferson
Contains
Basics of programming using java

Subjects

Content preview

ELEMENTARYPROGRAMMI
NGPRI
NCI
PLES
Def
ini
ti
onoft
erms
ComputerProgr
am:
Acomputerpr
ogr
am i
sasetofcodedi
nst
ruct
ionsgi
vent
othecomput
er,
and
repr
esentsalogi
calsol
uti
ontoaprobl
em.Itdi
rect
sacomput
eri
nper
for
mingv
ari
ous
operat
ions/
tasksonthedatasuppl
i
edtoi
t.
Computerpr
ogr
amsmaybewr it
tenbyt
hehardwar
emanufact
urer
s,Sof
twar
ehouses,
orapr
ogrammertosol
veuserprobl
emsonthecomput
er.
Pr
ogramming:
Pr
ogr
ammingist
hepr
ocessofdesi
gni
ngasetofi
nst
ruct
ions(
comput
erpr
ogr
ams)
whichcanbeusedt operfor
m apar ti
culartaskorsol veaspecificproblem.
I
tinvolvesuseofspeci alcharacter
s,signsandsy mbolsfoundi napar t
icul
ar
programmi nglanguaget ocreatecomput erinstr
uctions.
Thepr ogrammi ngprocessisquiteex t
ensi ve.Itincl
udesanaly zingofanappl i
cati
on,
designingofasol ut
ion,codi
ngf orthepr ocessor, t
estingtoproduceanoper at
ing
program, anddevelopmentofot herprocedur estomaket hesy stem functi
on.
Theprogr
am creat
edmustspeci
fyi
ndetai
lthel
ogi
cal
stepst
obet aken&themethod
ofpr
ocessingt
hedatai
nputint
othecomputeri
nor
dertocar
ryoutthespeci
fi
edt
ask.
Acomput erprogr
am perf
ormst hefoll
owing:
1.Accept sdataf
rom outsi
dethecomput erasit
sinput.
2.Carriesoutasetofprocessesont hedatawit
hinthecomput
ermemor
y.
3.Presentstheresul
tsofthi
spr ocessi
ngasitsoutput
,and
4.Storesthedataforfut
ureuse.

Pr
ogr
ammi
ngLanguages:
Apr ogr
ammi ngl
anguageisasetofsy mbols(alanguage)whi
chacomputer
programmerusestosolveagivenproblem usi
ngacomput er.
Thecomput ermustbeabletotransl
atetheseinst
ruct
ionsi
ntomachi
ne-
readabl
efor
m
whenar r
angedinaparti
cul
arsequenceoror der.

TERMSUSEDI
NCOMPUTERPROGRAMMI
NG
Sour
cepr ogr
am (
sourcecode)
Thet
erm Sour
cepr
ogr
am ref
erst
opr
ogr
am st
atement
sthatt
hepr
ogr
ammerent
ersi
n
theprogram edi
torwi
ndow,andwhichhav
enoty
etbeentr
anslat
edintomachi
ne-
readablefor
m.
Sourcecodei st
hecodeunderst
oodbythepr
ogr
ammer,andisusuall
ywri
tt
eninhi
gh-
l
ev ell
anguageorAssemblyl
anguage.
Objectcode(objectprogram).
Theterm Obj
ectcoderef
erstot
hepr
ogr
am codet
hati
sinmachi
ne-
readabl
e(bi
nar
y)
for
m.
Thi
sisthecode/l
anguagethecomputercanunder
stand,
andisproducedbyaCompiler
orAssembl
eraftert
ransl
ati
ngtheSourceprogr
am i
ntoafor
mt hatcanbereadi
l
yloaded
i
ntothecomputer.



-1-

,LANGUAGETRANSLATORS
Acomput eruses&st or
esinf or
mat i
oninbi naryf or
m, andt heref
or e,i
tcannot
under st
andpr ogramswr itt
eni neit
herhigh-levelorlow-levellanguages.Thi smeans
that,anyprogram codewr i
tteninAssembl yl anguageorhi gh-levellanguagemustbe
translat
edi nt
oMachi nelanguage, beforethecomput ercanr ecogni ze&r unthese
programs.
ATr anslatorisspecialsystem softwareusedt oconverttheSour cecodes( program
statementswr it
teninanyoft hecomput erpr ogrammi nglanguages)t ot rObj
hei ect
codes( comput erlanguageequi val
ents).
TheTr anslator
sr esideinthemai nmemor yofthecomput er
,anduset heprogram code
ofthehigh- l
evelorAssembl ylanguageasinputdata,changesthecodes, andgiv
est he
outputprogram inmachi ne-r
eadablecode.
I
naddi ti
on, t
ranslatorscheckf or&identi
fysomet ypesoferror
s( e.
g.,
Syntax/grammat icalerrors)thatmaybepr esentintheprogram bei
ngt r
anslat
ed.They
wil
lproduceer rormessagesi fthereisami st
akeinthecode.
Eachl
anguageneedsi
tsownt
ransl
ator
.Gener
all
y,t
her
ear
e3t
ypesofl
anguage
tr
ansl
ator
s:
1.Assembler.
2.Int
erpr
eter
.
3.Compiler
.
Note.I
nter
pret
ers&Compil
erstr
anslat
esour
ceprogr
amswr
it
teni
nhi
gh-
lev
el
l
anguagestothei
rmachi
nelanguageequi
val
ent
s.
Assembler
Anassembl
ert
ransl
atespr
ogr
amswr
it
teni
nAssembl
ylanguagei
ntomachi
nel
anguage
t
hatt
hecomput
ercanunder
standandex
ecut
e.
Funct
ionsofanAssembl
er.
1)
.Itcheckswhet
hert
hei
nst
ruct
ionswr
it
tenar
eval
i
d,andi
dent
if
iesanyer
ror
sint
he
pr
ogram.
TheAssembl erwi l
ldisplayt
heseerrorsaswel lasthecompl etesour ceandobj ect
programs.Ifthepr ogram hasnoerrors,t
hej obcont r
ol wi
l
lletitruni mmedi ately
,
orsav etheobj
ectpr ogram sothati
tmayr unitl
aterwi t
houttranslatingitagain.
2)
.Itassi gnsmemor ylocationstothenamest heprogrammeruses.
E.
g. ,
theAssembl erkeepsat ableofthesenamessot hati
fani nstructi
onr efersto
i
t,theAssembl ercaneasi l
ytel
lthelocati
ont owhichitwasassi gned.
3)
.Itgener atesthemachinecodeequi val
entoftheAssembl
yinst
ruct
ions.
Usuall
y, t
heAssembl ergeneratesamachinecodeonlywhennoerrorsar
edet
ect
ed.
Someoft heerrorsi
nclude;
-Ty pingmi stakes.
-Usi ngt hewr ongf
ormatf oraninstr
uct
ion.
-Speci fyingamemor yl ocat
ionoutsi
detherange0–2047.
Note.TheAssembl ercannotdetectLogicerror
s.Theprogrammerknowsof
theseerror
sonlywhent hepr
ogram isrun&t heresul
tspr
oducedar eincorr
ect(
not
whatt hepr
ogrammerexpected).Thepr ogrammermustt herefore,
gothrought
he
program &tryt
odiscoverwhyani ncor
rectresul
twasbeingpr oduced.

I
nter
pret
er

-2-

,Aninterpretertr
anslatesasourceprogram wor dbywor dorli
nebyli
ne.Thisal l
owst he
CPUt oexecut eonel i
neatat i
me.
TheInterpretertakesonelineofthesour ceprogram,tr
anslat
esiti
ntoamachi ne
i
nstructi
on, andtheni ti
simmediatel
yexecut edbyt heCPU.Itthentakest
henext
i
nstructi
on, tr
anslatesiti
ntoamachinei nstr
uction,
andt hent
heCPUexecut esit,andso
on.
Thetransl
atedl
inei
snotstor
edinthecomput
ermemor y.Ther
efor
e,ev
eryt
imet
he
progr
am isneededf
orexecut
ion,
ithastobet
ransl
ated.
Compil
er
Acompi
lert
ransl
atest
heent
ir
e/whol
esour
cepr
ogr
am i
ntoobj
ectcodeatonce,
and
thenexecutesi
tinmachinelanguagecode.Thesemachi necodeinstruct
ionscanthen
berunont hecomputertoperfor
mt heparti
cul
art
askasspeci fi
edinthehigh-l
evel
progr
am.
Theprocessoftransl
ati
ngapr ogr
am wr i
tt
eninahigh-
levelsour
celanguageinto
machinelanguageusi
ngacompi l
eriscal
ledCompilat
ion.
Foragi
venmachine,eachlanguagerequir
esitsownCompiler
.E.g.,f
oracomputert
o
beabl
etransl
ateaprogram wri
tt
eninFORTRANi nt
omachinelanguage;
thepr
ogram
mustpassthr
oughtheFORTRANcompi ler(whichmust‘
know’FORTRANaswel l
asthe
Machi
nelanguageofthecomput er
).
Theobjectcodefil
ecanbemadei ntoaf ull
yexecutabl
epr ogram bycar
ryi
ngouta
Linki
ngprocess,whichjoi
nstheobjectcodet oalltheotherfil
esthatar
eneededfort
he
executi
onoftheprogr am.Aft
erthelinkingprocess,anexecut abl
efi
lewihan.
t EXE
extensi
onisgenerated.Thisf
il
eisstor edonast oragemedi a.
Pointst
onot e.
 Th ej
obofaCompi l
eri
smuchmor ediff
icultthant hatofanAssemblerinthat,
a
singl
estatementi
nahigh-
level
languageisequi v al
enttomanymachi neinst
ructi
ons.
 Th ef
ormatofanAssemblyinst
ructi
onisf air
lyfixed,whil
ehigh-
lev
ellanguagesgivea
l
otoff r
eedom i
nthewaytheprogrammerwr itesstatements.
Funct
ionsofacompi
ler
.
ACompi
l
erper
for
mst
hef
oll
owi
ngt
asksdur
ingt
hecompi
l
ati
onpr
ocess:
1)
.I ti
dent if
iesthepr operor derofpr ocessi
ng, soast oexecutethepr ocessasf astas
possible&mi nimi zethest or
agespacer equi r
edi nmemor y.
2)
.I tall
ocat esspacei nmemor yf orthestor agel ocati
onsdefinedint hepr ogr
am tobe
execut ed.
3)
.I treadseachl i
neoft hesour cepr ogram &conv er
tsiti
ntomachi nel anguage.
4)
.I tchecksf orSy nt
axer r
or sinapr ogram (i.e.,
statementswhi chdonotconf ormto
thegr ammat ical r
ul esoft hel anguage) .I ftherearenosy ntaxerrors,itgener
ates
machi necodeequi valentt othegi venpr ogr am.
5)
.I tcombi nest hepr ogram ( machi ne)codegener atedwiththeappr opr i
ate
subrout i
nesf rom t helibrary.
6)
.I tproducesal isti
ngoft hepr ogram, i
ndicat i
nger r
ors,i
fany .
Di
ff
erencesbet
weenCompi
ler
sandI
nter
pret
ers
I
nter
pret
er Compi
ler
1.
Transl
ates&execut
eseachstat
ement 1.
Translat
esallt
hesourcecode
ofthesourcecodeoneatati
me. stat
ement satonceasauni tint
othei
r
correspondi
ngobjectcodes,befor
ethe
Thesourcecodei
nstr
uct
ioni
s
comput ercanexecut
ethem.

-3-

, t
ransl
ated&immediatel
yobeyedby ACompi lertransl
atestheent
iresource
t
hecomput erhar
dwarebefor
ethenext program fi
rsttomachinecode, and
i
nstr
ucti
oncanbet r
anslat
ed. thenthecodei sexecutedbytheCPU.
(
Transl
ati
on&executiongotoget
her
). (Transl
ati
on&execut ionareseparate
phases)


2.
Transl
atestheprogram eacht
imeiti
s 2.
Compil
edpr ogr
ams( objectcodes)can
neededforexecuti
on;hence,i
tis besavedonast oragemedi aandrun
slowert
hancompi li
ng. whenrequi
red;henceexecut esf
aster
thani
nter
pretedprograms.
3.
Int
erpretedobj
ectcodestakel
ess 3.
Compi
l
edprogr
amsrequi
remore
memor ycomparedtocompil
ed memoryast
hei
robj
ectfi
l
esar
elarger
.
programs. 4.
ForaCompil
er,t
hesy ntaxer
rorsar
e
4.
ForanInterpr
eter
,thesyntax repor
ted&corr
ectedaftert
hesource
(gr
ammat ical
)err
orsarereport
ed& codehasbeentransl
atedtoit
sobject
corr
ectedbeforetheexecuti
oncan codeequi
val
ent.
conti
nue. 5.
Oncet hesour ceprogram hasbeen
transl
ated,iti
snol ongeravail
abl
eto
5.
AnInterpretercanrel
ateerror theCompi ler,sotheerrormessages
messagest othesourceprogram, areusuallylessmeani ngful
.
whichisal waysavail
abletothe
Int
erpreter.Thismakesdebuggi ngofa
program easierwhenusingan
Int
erpreterthanaCompi ler
.

Li
nker
s&Loader
s
Computerpr
ogramsareusual
lydev
elopedinModul esorSubrout
ines(i
.e.
,progr
am
segmentsmeanttocar
ryoutt
hespecifi
crel
evanttasks).Duri
ngprogr
am transl
ati
on,
thesemodul
esaretr
anslat
edsepar
atel
yintothei
robject(machi
ne)codeequival
ents.
TheLinkeri
sautil
it
ysoftwarethataccept
stheseparatelyt
ranslatedprogram modules
asit
sinput,
andlogi
call
ycombi nesthem i
ntoonelogicalmodule, knownast heLoad
Modulethathasgotal
ltherequiredbi
tsandpiecesforthetranslatedprogram t
obe
obeyedbythecomputerhardware.
TheLoaderisaut
il
it
yprogram t
hattr
ansf
erstheloadmodule(
i.
e.t
heli
nkerout
put
)int
o
thecomputermemory,
readyfori
ttobeexecutedbythecomput
erhar
dware.
Sy
ntax
Eachprogramminglanguagehasaspecial
sequenceororderofwr
it
ingcharact
ers.
Theter
m Sy nt
axreferst
othegrammati
calrul
es,whichgover
nhowwor ds,symbols,
expr
essionsandstatementsmaybeformed&combi ned.
Semant
ics
Thesear
erul
es,
whi
chgover
nthemeaningofsy
ntax.Theydi
ctat
ewhathappens(
takes
pl
ace)whenapr
ogr
am i
srunorexecut
ed.

Rev
iewQuest
ions.
1.
Definethefoll
owingter
ms:
(i
). Comput erprogr
am.
(i
i)
.Pr ogrammi ng.

-4-
$8.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
mainarobinson293

Get to know the seller

Seller avatar
mainarobinson293 Meru university of science and technology
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
10 months
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions