Assignment Instructions

  1. Edit, compile, and run the following program on the UH UNIX shell:
    1. The purpose of this assignment is to learn how to use an array of structures.
    2. Modify the "struct card" structure and corresponding code in the card shuffling program cards.c to display the colors of the cards (red or black).
    3. Use an array of struct card in your program. The color will be a part of struct card. Don't use the color as a separate array.
    4. //structure definition
      struct card{
         char *rank;
         char suit[MAX];
         //** add the color of the cards here **
      };
      typedef struct card Card;
    5. Email your makefile and C program to the instructor, or show it to the instructor in class.
  2. For the submission guidelines and the grading guidelines, see the syllabus.

Example I/O

Display an ordered deck of cards:
  Ace of Clubs (black)
  Two of Clubs (black)
Three of Clubs (black)
 Four of Clubs (black)
 Five of Clubs (black)
  Six of Clubs (black)
Seven of Clubs (black)
Eight of Clubs (black)
 Nine of Clubs (black)
  Ten of Clubs (black)
 Jack of Clubs (black)
Queen of Clubs (black)
 King of Clubs (black)
  Ace of Diamonds (red)
  Two of Diamonds (red)
Three of Diamonds (red)
 Four of Diamonds (red)
 Five of Diamonds (red)
  Six of Diamonds (red)
Seven of Diamonds (red)
Eight of Diamonds (red)
 Nine of Diamonds (red)
  Ten of Diamonds (red)
 Jack of Diamonds (red)
Queen of Diamonds (red)
 King of Diamonds (red)
  Ace of Hearts (red)
  Two of Hearts (red)
Three of Hearts (red)
 Four of Hearts (red)
 Five of Hearts (red)
  Six of Hearts (red)
Seven of Hearts (red)
Eight of Hearts (red)
 Nine of Hearts (red)
  Ten of Hearts (red)
 Jack of Hearts (red)
Queen of Hearts (red)
 King of Hearts (red)
  Ace of Spades (black)
  Two of Spades (black)
Three of Spades (black)
 Four of Spades (black)
 Five of Spades (black)
  Six of Spades (black)
Seven of Spades (black)
Eight of Spades (black)
 Nine of Spades (black)
  Ten of Spades (black)
 Jack of Spades (black)
Queen of Spades (black)
 King of Spades (black)

shuffling deck ... 
 Five of Hearts (red)
 Nine of Diamonds (red)
  Ace of Diamonds (red)
 Four of Spades (black)
  Six of Spades (black)
  Ace of Clubs (black)
Queen of Clubs (black)
Seven of Clubs (black)
 Jack of Diamonds (red)
  Ace of Spades (black)
Three of Spades (black)
  Ten of Clubs (black)
  Two of Spades (black)
 Nine of Clubs (black)
Eight of Clubs (black)
  Six of Hearts (red)
 Nine of Hearts (red)
  Two of Clubs (black)
 Four of Hearts (red)
 Jack of Hearts (red)
 Jack of Clubs (black)
 Four of Diamonds (red)
Eight of Diamonds (red)
Eight of Hearts (red)
 Five of Clubs (black)
Three of Diamonds (red)
 King of Clubs (black)
  Six of Diamonds (red)
Queen of Spades (black)
  Ten of Spades (black)
  Ten of Hearts (red)
  Ten of Diamonds (red)
Eight of Spades (black)
 King of Spades (black)
Three of Clubs (black)
  Six of Clubs (black)
 Jack of Spades (black)
Queen of Diamonds (red)
Seven of Hearts (red)
  Ace of Hearts (red)
 King of Diamonds (red)
Seven of Diamonds (red)
 Four of Clubs (black)
 Five of Spades (black)
Seven of Spades (black)
 Nine of Spades (black)
  Two of Hearts (red)
  Two of Diamonds (red)
 King of Hearts (red)
Queen of Hearts (red)
 Five of Diamonds (red)
Three of Hearts (red)
Would you like to shuffle again?
If so, press "Enter" key. If not, press any other key. n


Click to validate the HTML code

Click to validate the CSS code