C Programming Absolute Beginner's Guide (3rd Edition)

(Romina) #1

{
switch (rank)
{
case 0:
return('A');
case 1:
return('2');
case 2:
return('3');
case 3:
return('4');
case 4:
return('5');
case 5:
return('6');
case 6:
return('7');
case 7:
return('8');
case 8:
return('9');
case 9:
return('T');
case 10:
return('J');
case 11:
return('Q');
case 12:
return('K');
}
}


// Function to get the user's bet between 1 and 5


int getBet()
{
int bet;


do //Will keep running until the user enters 0-5
{
printf("How much do you want to bet? (Enter a number ");
printf("1 to 5, or 0 to quit the game): ");
scanf(" %d", &bet);


if (bet >= 1 && bet <= 5)
{
return(bet);
}
else if (bet == 0)
{
exit(1);
}
else
{
printf("\n\nPlease enter a bet from 1-5 or ");
printf("0 to quit the game.\n");
}

Free download pdf