my project is :
Create a two dimensional array. The array will have 4 rows and 13 columns.
- Each row will be a different suit of cards.
- The columns will store integers that will represent the values of the card (e.g. 2, 3, 4...10, J, Q, K)
- Populate each row of the array appropriately and print out the value of the array so the output would look like this:
AD
2D
2D
4D
5D
...
10D
JD
QD
KD
AH
2H
i have coded
Code:
#include <stdio.h>
#include <stdlib.h>
#define VALUES 14
#define ACE 1
#define KING 13
#define QUEEN 12
#define JACK 11
enum suits{ clubs , diamonds , hearts , spades ,numOfSuits };
int main ( void )
{
int arry [numOfSuits] [ VALUES ]= { { 4 } , { 0,2,3,4,5,6,7,8,9,10,11,12,13 } };
for( int x = clubs; x < numOfSuits; x++ ) {
for ( int y = 0;y<VALUES;y++){
arry[x][y]=x*13+(y);
}
}
for( int x = clubs; x < numOfSuits; x++ ) {
for ( int y = 0;y<VALUES;y++){
switch ( arry [x][y]%13)
{
case ACE: printf("A"); break;
case QUEEN: printf("Q"); break;
case JACK: printf("J"); break;
case KING: printf("K"); break;
default: printf("%d",arry[x][y]%13);
}
switch ( arry[x][y]/13 )
{
case clubs: printf(" clubs\n"); break;
case diamonds: printf(" diamonds\n"); break;
case hearts: printf(" hearts\n"); break;
case spades: printf(" spades\n"); break;
}
}
}
return 0;
}
and it skips K output, what am i doing wrong?