Question: please help with 2.2 in C Card Games A shuffle is an array of 52 pairs of integers. The first of the pair is the

please help with 2.2 in C
Card Games
A shuffle is an array of 52 pairs of integers. The first of the pair is the card type (0-13 representing Ace, 2, 3, .... King) and the second representing the suit (hearts, diamonds, clubs, spades). Thus a pair of numbers describes a unique card in the deck. For example, {6,3} would describe the Six of Clubs, and {13,1} would be the King of Hearts.
2.1 Shuffling
Write a function (void fill(shuffle[52][2])) to fill a shuffle with 52 random integer pairs, BUT, as with your playing cards, there must be exactly one of each pair in the shuffle.
2.2 Compact Data Representation
A hand is an array of seven unsigned chars. Each char represents one card. We use a four bit field in the char for each of the two numbers above: the four most significant bits [bits 7...4] represent the card number (1-13) and the lower four [bits 3...0] represent the suit.
Write functions to:
a) convert two integers (from a shuffle for example) into a char as above.
unsigned char convert(int card, int suit);
b) get the integer suit from a char.
int gsuit(unsigned char card);
c) get the integer card from a char.
int gcard(unsigned char card);
All functions must print a warning message and return CARD ERROR (already defined at top of file) if they get invalid input (such as suit > 4).
Write code which verifies these functions work properly and prints results.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!