Write C program about the blackjack game it should make use

Write C program about the blackjack game, it should make use of several of the concepts, like arrays, loops, strings, functions, decisions.

Solution

#include <stdio.h>

#include <stdlib.h>
#include <time.h>


int main(){
char combo [5][14]={0};
char colorOfCard,cardinDeck,enter=\'y\',tmp;
int hd=0,dlr,c_v,sft=0;


printf (\"Blackjack\ \ \ \");
printf (\"dlr stands at all (hard or soft) 17\'s!\ \ \ \");


srand (time(0));


while (enter==\'y\'){


do{
colorOfCard = 3+rand()%(6-3+1);
cardinDeck = 1+rand()%(13-1+1);
}
while (combo[colorOfCard-3][cardinDeck]==1);
combo [colorOfCard-3][cardinDeck] = 1;


switch (cardinDeck){
case 1:
cardinDeck = \'A\'; c_v=11; sft=1;
break;
case 2:
cardinDeck = \'2\'; c_v=2;
break;
case 3:
cardinDeck = \'3\'; c_v=3;
break;
case 4:
cardinDeck = \'4\'; c_v=4;
break;
case 5:
cardinDeck = \'5\'; c_v=5;
break;
case 6:
cardinDeck = \'6\'; c_v=6;
break;
case 7:
cardinDeck = \'7\'; c_v=7;
break;
case 8:
cardinDeck = \'8\'; c_v=8;
break;
case 9:
cardinDeck = \'9\'; c_v=9;
break;
case 10:
cardinDeck = \'X\'; c_v=10;
break;
case 11:
cardinDeck = \'J\'; c_v=10;
break;
case 12:
cardinDeck = \'Q\'; c_v=10;
break;
case 13:
cardinDeck = \'K\'; c_v=10;
break;
}


printf (\"%c%c\ \",colorOfCard,cardinDeck);


hd=hd+c_v;


if (hd>21 && sft && c_v==11)
hd -= 10;


printf (\"hd = %d\ \", hd);


if (hd>21) {
printf (\"You lost!\");return 0;
}
if (hd == 21) {
printf (\"Blackjack!\");return 0;
}
printf (\"Hit?(y/n)\"); scanf (\" %c\", &enter);
}


dlr = 17+rand()%(26-17+1);


if (dlr>hd && dlr<=21)
printf (\"dealerlr has %d!You lost!\",dlr);
else
printf (\"dealerlr has %d! Congratulations!\",dlr);


return 0;
}

Write C program about the blackjack game, it should make use of several of the concepts, like arrays, loops, strings, functions, decisions.Solution#include <
Write C program about the blackjack game, it should make use of several of the concepts, like arrays, loops, strings, functions, decisions.Solution#include <

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site