Skip to content

Commit 9c709d5

Browse files
Add files via upload
1 parent de3d9bc commit 9c709d5

File tree

2 files changed

+152
-0
lines changed

2 files changed

+152
-0
lines changed

Betting_Game/Betting_Game.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include<stdio.h>
2+
#include<stdlib.h>
3+
#include<time.h>
4+
int n,b,r,*a;
5+
6+
void start(){
7+
srand(time(0));
8+
9+
a = (int*)malloc(3*sizeof(int));
10+
*a=rand()%3;
11+
*(a+1)= rand()%3;
12+
*(a+2)= rand()%3;
13+
14+
if(n>0){
15+
16+
printf("you have currently $%d \n",n);
17+
printf("enter the bet amount $");
18+
scanf("%d",&b);
19+
if(b<=n){
20+
printf("find the place of queen[chose 1,2,3] : ");
21+
scanf("%d",&r);
22+
if(*a==(r-1) ){
23+
printf("congratulations you win!\n");
24+
n=n-b+(3*b);
25+
printf("now you have $%d\n",n);
26+
printf("______________________________\n");
27+
}
28+
else{
29+
printf("Better luck Next time\n");
30+
n=n-b;
31+
printf("now you have $%d \n",n);
32+
printf("______________________________\n");
33+
}
34+
}else{
35+
printf("you have only $%d and you Bet $%d \n",n,b);
36+
37+
}
38+
39+
}
40+
else{
41+
printf("you are not eligible to play game \n you ave no money\n");
42+
}
43+
free(a);
44+
45+
}
46+
int main(){
47+
48+
49+
50+
printf("______________________________\n");
51+
printf(" BETTING GAME\n");
52+
printf("______________________________\n");
53+
printf(" ***** ***** *****\n");
54+
printf(" * * * * * *\n");
55+
printf(" * j * * Q * * K *\n");
56+
printf(" * * * * * *\n");
57+
printf(" ***** ***** *****\n");
58+
printf("______________________________\n");
59+
printf("rules : \n");
60+
printf("1) you have to chose between 1 to 3 \n");
61+
printf("2) you are allow to play till you have $0 \n");
62+
printf("3) if you will win then you will get 3*(BET AMOUNT)\n\n\n");
63+
printf("how many amount you have $");
64+
scanf("%d",&n);
65+
int f;
66+
f=n;
67+
68+
printf("\n\n*******************************************\n");
69+
printf(" GAME START \n");
70+
printf("*******************************************\n\n");
71+
//printf("you want to play game(y/n):");
72+
//char m;
73+
//scanf("%c",&m);
74+
while(n!=0){
75+
start();
76+
//printf("you want to play game again!(y/n):");
77+
//scanf("%c",&m);
78+
}
79+
printf("\n\n\n\nyou come with $%d\n",f);
80+
printf("now you have $%d\n\n\n",n);
81+
printf("thank you for play!\n\n\n");
82+
return 0;
83+
84+
}
85+
86+

Betting_Game/Betting_Game_Output.txt

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
______________________________
2+
BETTING GAME
3+
______________________________
4+
***** ***** *****
5+
* * * * * *
6+
* j * * Q * * K *
7+
* * * * * *
8+
***** ***** *****
9+
______________________________
10+
rules :
11+
1) you have to chose between 1 to 3
12+
2) you are allow to play till you have $0
13+
3) if you will win then you will get 3*(BET AMOUNT)
14+
15+
16+
how many amount you have $15
17+
18+
19+
*******************************************
20+
GAME START
21+
*******************************************
22+
23+
you have currently $15
24+
enter the bet amount $4
25+
find the place of queen[chose 1,2,3] : 1
26+
Better luck Next time
27+
now you have $11
28+
______________________________
29+
you have currently $11
30+
enter the bet amount $7
31+
find the place of queen[chose 1,2,3] : 3
32+
congratulations you win!
33+
now you have $25
34+
______________________________
35+
you have currently $25
36+
enter the bet amount $20
37+
find the place of queen[chose 1,2,3] : 2
38+
Better luck Next time
39+
now you have $5
40+
______________________________
41+
you have currently $5
42+
enter the bet amount $3
43+
find the place of queen[chose 1,2,3] : 2
44+
Better luck Next time
45+
now you have $2
46+
______________________________
47+
you have currently $2
48+
enter the bet amount $2
49+
find the place of queen[chose 1,2,3] : 3
50+
Better luck Next time
51+
now you have $0
52+
______________________________
53+
54+
55+
56+
57+
you come with $15
58+
now you have $0
59+
60+
61+
thank you for play!
62+
63+
64+
65+
Process returned 0 (0x0) execution time : 74.211 s
66+
Press any key to continue.

0 commit comments

Comments
 (0)