Im trying to write a blackjack game for class. Im confusedabout how to use funct
ID: 3609811 • Letter: I
Question
Im trying to write a blackjack game for class. Im confusedabout how to use functions in C. I dont know how to call themto the main function. I think my logic is correct, but myunderstanding of the technical aspect isnt there. Forinstance, in the compare function I dont know how to access thefunction so that it displays what it prints out. Here is thecode I have written so far. I would appreciate any help:#include<stdio.h>
#include <stdlib.h>
#include <time.h>
int randNum(void);
int Dealer(Dcard1, Dcard2, Dscore);
int PlayerScore(card1, card2, choice, score);
int Compare
int main(void)
{
srand(time(NULL))
printf("Welcome to Blackjack!");
}
int randNum(void)
{
return rand() % 9 + 1;
}
int Dealer(int Dcard1, Dcard2, Dscore)
{
randNum() = Dcard1
randNum() = Dcard2
printf("Dealer shows: %d", Dcard1);
Dscore = Dcard1 + Dcard2
while (Dscore < 16)
{
Dscore = randNum() + Dscore
}
return Dscore;
}
int PlayerScore(card1, card2, choice, score)
{
randNum() = card1
randNum() = card2
score = card1 + card2
printf("You have %d", score);
printf("Press 0 to hit and 1 to stay");
scanf("%d", &choice);
while(score < 21 && choice != 1)
{
score = score + randNum();
printf("You have %d", score);
printf("Press 0 to hit and 1 tostay");
scanf("%d", &choice);
}
return score;
}
int Compare(x)
{
if(Dealer > 21 && PlayerScore <= 21)
printf("Dealer busts, youWIN!");
if(PlayerScore > 21)
printf("Bust, You LOSE");
if(PlayerScore == 21)
printf("Player has Blackjack! You win!");
if(PlayerScore == Dealer)
printf("It is a tie, you LOSE");
if(PlayerScore > Dealer)
printf("You WIN");
if(Dealer > PlayerScore)
printf("You Lose");
return x;
}