Docsity

c programing examples, Exercises of Computer Science

Toggle sidebar
bg1
1993 Paper 6 Question 5
Programming in C
Two identical packs of ordinary playing cards (52 different cards in a pack) are
shuffled and placed face downwards on a table. Two players then play a game of
Snap. Each player is allocated one pack and at each turn in the game one card in
each pack is turned up and the two upturned cards are compared. If the cards are
the same (i.e. match in every respect) a snap-turn is declared. A game ends when
all 52 pairs have been compared.
Write a C program which will simulate the game for the purposes of determining
the probability of there being at least one snap-turn in a game. [20 marks]
Note: you may assume the existence of a random number generator but must state
its properties.
1

Partial preview of the text

Download c programing examples and more Exercises Computer Science in PDF only on Docsity!

1993 Paper 6 Question 5

Programming in C

Two identical packs of ordinary playing cards (52 different cards in a pack) are shuffled and placed face downwards on a table. Two players then play a game of Snap. Each player is allocated one pack and at each turn in the game one card in each pack is turned up and the two upturned cards are compared. If the cards are the same (i.e. match in every respect) a snap-turn is declared. A game ends when all 52 pairs have been compared.

Write a C program which will simulate the game for the purposes of determining the probability of there being at least one snap-turn in a game. [20 marks]

Note: you may assume the existence of a random number generator but must state its properties.