Generating a deck of cards in C -


i need assignment. supposed generate , print 52 cards, i'm having trouble understanding how print "ace", "2".....etc.

for(i=0; < 52; i++) {      if(i%13==0)     {       printf("card %2d = king %s\n", i,suits[i/13]);      }     else if(i%13==1)     {       printf("card %2d = ace %s\n", i,suits[i/13]);      }     else if(i%13==11)     {       printf("card %2d = jack %s\n", i,suits[i/13]);      }     else if(i%13==12)     {       printf("card %2d = queen %s\n", i,suits[i/13]);      }     else     {        printf("card %2d = %2d %s\n", i, i%13, suits[i/13]);      } }  

another solution adding more condition loop "king" "ace" "jack" , "queen"


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -