Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

KI

NGDOM OFSAUDIARABI
A|JAZANUNI
VERSI
TY

COLLEGEOFSCI
ENCE

2021-
2022:Semest
erI
I

ASSI
GNMENT-I

I
ntroducti
ontoprogrammi
ng
Cour
seName CourseCode CSC-
301
usi
ngC++
Syl
labus Chapter1&2 Max.Mar ks 10Mar
ks
Dateof Lastdateof
12/02/2022 26/
02/
2022
Announcement submission
St
udentName ‫ﺎﺏ‬‫ﺑ‬‫ﻠﻲﺫ‬
‫ﻧﻲﻋ‬ ‫ﺎ‬
‫ﻣ‬‫ﺍ‬ StudentI
D 202007533

Not
e:AnswerALLquest
ions.Eachquest
ioncar
ri
esTWOmar
ks.

1.Wr
it
eanal
gor
it
hm t
ofi
ndt
hel
argeroft
wonumber
s.

Ans.

St
ep1:St
art 
St
ep2:I
nputthev al
uesofA, BCompar
eAandB.
 
St
ep3:I
fA>Bt hengot ostep5 
St
ep4:El
sePrint“Bislargest
”gotoSt
ep6
St
ep5:Pr
int“Aislargest
” 
St
ep6:St
op

2.Wri
teanal
gorit
hm t
odi
spl
ayoddnumber
sfr
om 25t
o75usi
ng
r
epeti
ti
onconstr
uct
.

Ans.

St
ep1:Start
St
ep2:Assigni=25
St
ep3:Repeatsteps4,
5&6unt
ili
=75r
eaches
St
ep4:i
fi%2!=0gotostep5
St
ep5:Printi
St
ep6:Comput ei=i
+1
St
ep7:Stop
3.Solvethef
oll
owingari
thmet
icexpr
essi
on(
stepbyst
ep)byappl
yi
ng
orderofpr
ecedencesuppor
tedbyC++

5+10*4–6%2+30/5–7

Ans.

Thedivisi
onandmulti
pli
cat
ionhavethesamel
evelofpri
ori
ty,al
sothe
addit
ionandsubst
ruct
ionhavethesame,sowestartf
rom l
efttori
ght
,
star
ti
ngwi tht
hehi
gherinpri
ori
ty.

St
ep1:10*4 =40

St
ep2:6%2=0

St
ep3:30/5=6

Wewi
llhav
e 5+40–0+6–7

St
ep4:5+40=45

St
ep5:45+6=51

St
ep6:51–7=44

Answer
=44
4.Wri
teaC++progr
am t
oinputt
wonumber
sf r
om keyboard,
findt
hei
r
sum anddi
spl
ayt
henumbersandt
hesum onthescreen.

Ans.
5.Gi
veexampl
esofcor
rectandi
ncor
rectv
ari
abl
esnames(
5foreach)
.

Ans.

S.
No Cor
rectVar
iabl
eNames I
ncor
rectVar
iabl
eNames

1. Age 1age

2. Dai
l
yHour
s Dai
l
yHour
s

3. Pay
Rat
e Pay
*rat
e

4. Cl
i
ent
Name C.
N

Cour
seTeacher RomaFay
az

You might also like