Can anyone help me to make this program work in C language, this is a blackjack game
#include
#include
#include
void deal(int, int&)
void deal(int, int&, int&)
int getbet(int);
int main()
{
int totdealer, totplayer;
int money, bet, aces;
char yesno = 'Y';
_Bool again;
srand(time(0));
printf("How much money do you have? ");
scanf("%d" , money);
while (money>0 && toupper(yesno) ==
'Y')
{
bet = getbet(money);
totdealer = 0;
deal(2, totdealer);
aces = 0;
totplayer = 0;
deal(2, aces, totplayer);
printf("Your total is %d " ,
totplayer);
printf("\n You have %d aces" ,
aces);
again = false;
while (totdealer<21 &&
totplayer<21 && !again)
{
printf("\n do
you want another card? ");
scanf("%d " ,
yesno);
if
(toupper(yesno) == 'Y')
{
deal(1, aces, totplayer);
printf( "Your total is %d " , totplayer);
printf( " \n You have %d aces" , aces );
}
else
again = true;
}
printf( " \n Dealer total: %d " ,
totdealer);
printf(" \n Your total: %d " ,
totplayer);
if (totdealer>totplayer ||
totplayer>21)
money -=
bet;
else if (totdealer
money += bet;
printf( "\n Game over\nYou have $
%d left" , money);
if (money>0)
{
printf( "\n Play
again (Y/N)?");
scanf( "%d " ,
yesno);
}
}
//system("pause");
return 0;
}
void deal(int num, int& tot)
{
int i, n;
for (i = 0; i {
n = rand() % 13 + 1;
if (n == 1)
tot += 11;
else if (n >= 10)
tot += 10;
else
tot += n;
}
}
void deal(int num, int& aces, int &tot)
{
int i, n;
for (i = 0; i {
n = rand() % 13 + 1;
if (n == 1)
{
aces++;
tot += 11;
}
else if (n >= 10)
tot += 10;
else
tot += n;
}
if (tot>21)
if (aces == 0)
return;
else
{
aces--;
tot -= 10;
}
}
int getbet(int money)
{
int bet;
printf( "You have $ %d enter your bet: " ,
money);
scanf("%d ", bet);
while (bet>money)
{
printf( "\n You cannot bet more
then you have!!!");
printf( "\n You have $ %d enter
your bet: " , money );
scanf("%d" , bet);
}
return bet;
}
IF YOU FACE ANY PROBLEM LET ME KNOW IN THE COMMENTS
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
void deal(int num, int tot)
{
int i,n;
for (i = 0; i<num;i++){
n = rand() % 13 +
1;
if (n == 1)
tot
+= 11;
else if (n >=
10)
tot
+= 10;
else
tot
+= n;
}
}
void deal1(int num, int& aces, int &tot)
{
int i, n;
for (i = 0; i {
n = rand() % 13 +
1;
if (n == 1)
{
aces++;
tot
+= 11;
}
else if (n >=
10)
tot
+= 10;
else
tot
+= n;
}
if (tot>21){
if (aces == 0)
return;
else
{
aces--;
tot
-= 10;
}
}
}
int getbet(int money)
{
int bet;
printf( "You have $ %d enter your bet: " ,
money);
scanf("%d ", &bet);
while (bet>money)
{
printf( "\n You cannot
bet more then you have!!!");
printf( "\n You have $ %d
enter your bet: " , money );
scanf("%d" ,
&bet);
}
return bet;
}
int main()
{
int totdealer, totplayer;
int money, bet, aces;
char yesno = 'Y';
bool again;
printf("How much money do you have? ");
scanf("%d" , money);
while (money>0 && toupper(yesno) ==
'Y')
{
bet =
getbet(money);
totdealer = 0;
deal(2, totdealer);
aces = 0;
totplayer = 0;
deal1(2, aces,
totplayer);
printf("Your total is %d
" , totplayer);
printf("\n You have %d
aces" , aces);
again = false;
while (totdealer<21
&& totplayer<21 && !again)
{
printf("\n
do you want another card? ");
scanf("%c",&yesno);
if
(toupper(yesno) == 'Y')
{
deal1(1,
aces, totplayer);
printf(
"Your total is %d " , totplayer);
printf(
" \n You have %d aces" , aces );
}
else
again
= true;
}
printf( " \n Dealer
total: %d " , totdealer);
printf(" \n Your total:
%d " , totplayer);
if
(totdealer>totplayer || totplayer>21)
money
-= bet;
else if
(totdealer<totplayer)
money += bet;
printf( "\n Game
over\nYou have $ %d left" , money);
if (money>0)
{
printf(
"\n Play again (Y/N)?");
scanf(
"%c " , &yesno);
}
}
return 0;
}
Can anyone help me to make this program work in C language, this is a blackjack...
C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. I am using printf and scanf. Instead of printf and scanf use cin and cout to make the program run. after this please split this program in three files 1. bill.h = contains the class program with methods and variables eg of class file class bill { } 2. bill.cpp = contains the functions from class...
Convert this C++ language to PEP/8 assembly language. #include <stdio.h> int main(void) { int num, rem; printf("Enter a number: "); scanf("%d", &num); printf("Roman numerals: "); while(num != 0) { if (num >= 1000) // 1000 - m { printf("m"); num -= 1000; } else if (num >= 900) // 900 - cm { printf("cm"); num -= 900; } else if (num >= 500) // 500 - d { printf("d"); num -= 500; } else if (num >= 400) // 400 - cd { printf("cd"); num -= 400; } else if (num >= 100) // 100 - c { printf("c"); num -= 100; } else if (num >= 90) // 90 - xc { printf("xc"); num -= 90; } else if (num >= 50) // 50 - l { printf("l"); num -= 50; } else if (num >= 40) // 40 - xl { printf("xl"); num -= 40; } else if (num >= 10) // 10 - x { printf("x"); num -= 10; } else if (num >= 9) // 9 - ix { printf("ix"); num -= 9; } else if (num >= 5) // 5 - v { printf("v"); num -= 5; } else if (num >= 4) // 4 - iv { printf("iv"); num -= 4; } else if (num >= 1) // 1 - i { printf("i"); num -= 1; } } return 0;}
Using C, I need help debugging this program. I have a few error messages that I'm not sure how to fix. Here is the code I have: /* * C Program to Print a Linked List in Reverse Order */ #include <stdio.h> #include <stdlib.h> struct node { int num; struct node *next; }; int main() { struct node *p = NULL; struct node_occur *head = NULL; int n; printf("Enter data into the list\n"); create(&p); printf("Displaying the nodes in the list:\n");...
C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the class program with methods and variables 2. bill.cpp = contains the functions from class file 3. main.cpp = contains the main program. Please split this program into three files and make the program run. I have posted the code here. #include<iostream>...
C LANGUAGE I just need the void push() function, which inserts new node to the front of the list #include<stdio.h> #include<stdlib.h> typedef struct node { int data; struct node *next; } Node; //Creating head a as a global Node* Node *head; /* Given a node prev_node, insert a new node after the given prev_node */ void insertAfter (Node * prev_node, int new_data) { /*1. check if the given prev_node is NULL */ if (prev_node == NULL) { printf ("the given...
please rewrite or convert this C program into Assembly language and please make a notice of which function is which! #include <stdio.h> #include <stdlib.h> void printMonthYear(int mon,int year); void printDaysOfWeek(); void printDays(int mon,int year); int getFirstDayOfMonth(int mon, int year); int getNumOfDaysInMonth(int mon, int year); int main(void) { int mon=-1; int year= -1; printf("Month : "); fflush(stdout); scanf("%d",&mon); if(mon < 1|| mon > 12){ printf("Invalid month >.<!: %d ! Must be between 1 and 12\n",mon); return 1; } printf("Year...
I need the programming to be in language C. I am using a program called Zybook Prompt: Write a statement that outputs variable numObjects. End with a newline. Given: #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); return 0; } What I did so far. I am not sure if its right tho? #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); printf(" num Objects is "); printf("%d\n", userAge); return 0; }
Need help with this C program? I cannot get it to compile. I have to use Microsoft Studio compiler for my course. It's a word game style program and I can't figure out where the issue is. \* Program *\ // Michael Paul Laessig, 07 / 17 / 2019. /*COP2220 Second Large Program (LargeProg2.c).*/ #define _CRT_SECURE_NO_DEPRECATE //Include the following libraries in the preprocessor directives: stdio.h, string.h, ctype.h #include <stdio.h> /*printf, scanf definitions*/ #include <string.h> /*stings definitions*/ #include <ctype.h> /*toupper, tolower...
Can someone tell me why this is not printing in the screen. I know i commented out the first couple functions but the last one is not working. --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #include <stdio.h> #include <stdlib.h> #include <time.h> #define ROWS 5 #define COLS 5 #define FREE 2 #define SCALE 15 #define SHIFT 1 #define MAXVAL 75 #define FALSE 0 #define TRUE 1 void welcomeScreen(); void clearScreen(); void displayExplicitCard(); void displayCard(); void displayRandomCard(); void fillCardRand(); void setValue(); void displayBingoCard(); void initializeArrays (); int main...
Convert the C program into a C++ program.Replace all C input/output statements with C++ statements (cin, cout, cin.getline) . Re-make the func function by the following prototype: void func( double, double &); #include int user_interface(); double func(double); void print_table(); int main (int argc, char *argv[]) { print_table(user_interface()); return 0 ; } int user_interface(int val){ int input = 0; printf("This function takes in x and returns an output\n"); printf("Enter Maximum Number of X:"); scanf("%d", &input);...