PROBLEMS
ON
CHAPTER
6
1.
Use a FOR loop
to
place one
of
four numbers
1,2,3,4
randomly
in
five
array
variables'
•
32
card(1), card(2), card(3), card(4), card(5).
It
does
not
matter
If
some
of
the four numbers
are
repeated.
Use
a second FOR
loop
to
output the values
of
the
five
card variables.
2.
Imagine
that
the
four
numbers
1,2,3,4
represent
'Hearts;
Clubs:
'DIamondS:
Spades
What extra program lines would need
to
be inserted
to
get output
in
the form
of
these
words Instead
of
numbers?
3.
Use a FOR loop
to
place
five
random numbers
In
the
range 1
to
13
in
an
array
of
five
variables:
card(1), card(2), card(3),
CfJrd(4)
and card(5).
Use a second FOR loop
to
output
fhe
values
of
the
five
card variables.
4.
Imagine that
the
random numbers generated
in
problem 1 represent cards.
Write
down
the
extra statements that would cause the following output:
Number
Output
•
1
the word
'Ace
2
to
10
the actual number
11
the
word
:Jack'
12
the word 'Queen'
13
the word 'King'
•
•
12/84