You are on page 1of 1

Exerc

ise1:Writeaprogramthatuse
sa ni
ntegervecto
randme mbe
rfu nct
ionsfromthevect
orclas
s
tostor
er andomnumbe r
sintothevect
or.Theusershouldfirs
tchoosethevectorsi
zeandrangeof
rando
mnu mberstobefill
ed(e.
g.numbersbet
wee n5a nd1 0
)andt henahisto
gr amisdi
spl
ayedon
thescr
e e
ns ho
wingfrequencyofeachofthenumbersstored.

Samp
leo
utp
ut:

Ent
erv
ect
ors
ize
:10[
ENTER]

Ent
ert
her
angeo
frando
mnu
mbe
rs:1 5[
ENTER]

*
***
***
***
***
***
*OUTPUT*
***
***
***
***
***
*

Yo
urde
sir
edv
ect
ori
s:1 2 1 3 5 4 2 3 4 3

Fr
equ
enc
ydi
str
ibu
tio
n(Hi
sto
gram)
:

1
:2t
ime
s

2
:2t
ime
s

3
:3t
ime
s

4
:2t
ime
s

5
:1t
ime
s

Exerci
se2 :Usethestri
ngc l
asstodec
lar
eas tri
ngarrayandsto
ret henamesofallthecour
sesin
SE Electri
calthi
ss emester
.Afterthec o
ursename sarest
ored,u s
es o
rt()functi
onfromt he
<al
gori
t hm>headertoso r
tt hes
tri
ngarrayanddispl
aythere
sults
.Youmu stdes
cribethemethod
forusingt hesort(
)fu ncti
onandalsothealgori
thm t
hatworkswhe nitisusedt osortstr
ing
var
iabl
e s.

You might also like