Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

The Dice Game in C-Language


The Dice Game

Description: The Dice Game is the result of different and innovative thinking. The idea is to play a game, made by a simple code in C-Language. No graphics, just a simple game. Nothing more to say. Simply, download the code, compile it and start playing.
The download link is given below:
Download the C-Program file of this Game.


            Compile and Play
color>


Rules :color>



1.Every Player gets 100$.

2. Every Player bet 10$ on a number.

3. Dice will be thrown. A random number will generate.

4. The closest bet number to the dice will win.

5.If both players bet the same number, no prize. Better Luck, Next time !!

6. If no money left, then you have lost.

7. The last Player with money, WINS !!!

8. In the Best of 3 match, two-player(s) will be fighting for only three rounds. The major winner of those three rounds will win. However, if both players win only 1 round or no round, then it will call a "Draw".


About :color>



Hello guys...
Another C-program game is here.

This is a product of - ProgramJoy.blogspot.com

This is purely for entertainment and fun for new programmers or beginners.

If any damage caused by this product: Any kind of damage (hardware or software related) by this product is unintentional and ProgramJoy is not responsible for this any kind of damage.

The code is also available on our Blog/Website: https://programjoy.blogspot.com

Follow us on Facebook: https://facebook.com/programjoyofficial

Twitter: @ProgramJoy

Email: [email protected]

Please, subscribe and give a thumbs up, if you like the game.


CODE---->


#include
#include
#include
void str_gm();void rules();void about();void Exit();void delay(int);void menu();void PVP();void PVC();void BST3();
void str_gm()
{
int c;
while(1)
{

system
("cls");
printf("\n1.Player Vs. Player\n2.Player Vs. Computer\n3.Best of 3(Player Vs Player)\n4.Main Menu\n");
printf("Your Choice: ");
scanf("%d",&c);
printf("\n\n");
switch(c)
{
case 1: PVP();
break;
case 2: PVC();
break;
case 3: BST3();
break;
case 4: system("cls");
menu();
break;
default: printf("\nInvalid Choice. Try again.");
break;
}
}
}
void PVP()
{
int p1,p2,m1=100,m2=100,x;
int rand_num,dif1,dif2;
while(1)
{
system("cls");
printf("\n\n\"Player 1\", Choose a number between (1-10): ");
scanf("%d",&p1);
while(1)
{
if(p1>=1&&p110)
break;
else
{
printf("\n\"Player 1\", please, choose a number between(1-10): ");
scanf("%d",&p1);
}
}
printf("\n\n\"Player 2\", Choose a number between (1-10): ");
scanf("%d",&p2);
while(1)
{
if(p2>=1&&p210)
break;
else
{
printf("\n\"Player 2\", please, choose a number between(1-10): ");
scanf("%d",&p2);
}
}
rand_num=rand()%10;
printf("\nThe dice says...");
delay(3000);
printf("\n\t%d\n",rand_num);
dif1=rand_num-p1;
dif2=rand_num-p2;
if(dif10)
dif1=dif1*(-1);
if(dif20)
dif2=dif2*(-1);
if(dif1dif2)
{
m1=m1+10;
m2=m2-10;
printf("\n\"Player 1\" has won this round. \n");
printf("\nSo, \"Player 1 has %d$ money.\"",m1);
printf("\nSo, \"Player 2 has %d$ money.\"",m2);
}
else if(dif1==dif2)
{
m1=m1+0;
m2=m2+0;
printf("\n\"No Player\" has won this round. \n");
printf("\nSo, \"Player 1 has %d$ money.\"",m1);
printf("\nSo, \"Player 2 has %d$ money.\"",m2);
}
else
{
m1=m1-10;
m2=m2+10;
printf("\n\"Player 2\" has won this round. \n");
printf("\nSo, \"Player 1 has %d$ money.\"",m1);
printf("\nSo, \"Player 2 has %d$ money.\"",m2);
}
delay(2000);
printf("\n\n\nNow, Press 1 to continue and press 0 to for main menu(do not enter other value): ");
scanf("%d",&x);
if(x==1)
system("cls");
else if(x==0)
{
system("cls");
menu();
break;
}
else
{
while(x!=1)
{
printf("\npress 1 to continue and press 0 for main menu(do not enter other value): ");
scanf("%d",&x);
if(x==1)
system("cls");
else if(x==0)
{
system("cls");
menu();
break;
}
}
}
if(m2==0)
{
printf("\n\nHoorah !!! Player 1 Won !!!");
delay(8000);
break;
}
if(m1==0)
{
printf("\n\nHoorah !!! Player 2 Won !!!");
delay(8000);
break;
}
}
}
void PVC()
{
int p1,p2,m1=100,m2=100,x; //p2 is computer.
int rand_num,rand_comp,dif1,dif2;
while(1)
{
system("cls");
printf("\n\n\"Player 1\", Choose a number between (1-10): ");
scanf("%d",&p1);
while(1)
{
if(p1>=1&&p110)
break;
else
{
printf("\n\"Player 1\", please, choose a number between(1-10): ");
scanf("%d",&p1);
}
}
printf("\n\n\"Computer\", Choosing a number between (1-10): ");
rand_comp=rand()%10;
delay(2000);
printf("%d",rand_comp);
p2=rand_comp;
rand_num=rand()%10;
printf("\nThe dice says...");
delay(3000);
printf("\n\t%d\n",rand_num);
dif1=rand_num-p1;
dif2=rand_num-p2;
if(dif10)
dif1=dif1*(-1);
if(dif20)
dif2=dif2*(-1);
if(dif1dif2)
{
m1=m1+10;
m2=m2-10;
printf("\n\"Player 1\" has won this round. \n");
printf("\nSo, \"Player 1 has %d$ money.\"",m1);
printf("\nSo, \"Computer has %d$ money.\"",m2);
}
else if(dif1==dif2)
{
m1=m1+0;
m2=m2+0;
printf("\n\"No one\" has won this round. \n");
printf("\nSo, \"Player 1 has %d$ money.\"",m1);
printf("\nSo, \"Computer has %d$ money.\"",m2);
}
else
{
m1=m1-10;
m2=m2+10;
printf("\n\"Computer\" has won this round. \n");
printf("\nSo, \"Player 1 has %d$ money.\"",m1);
printf("\nSo, \"Computer has %d$ money.\"",m2);
}
delay(2000);
printf("\n\n\nNow, Press 1 to continue and press 0 for main menu(do not enter other value): ");
scanf("%d",&x);
if(x==1)
system("cls");
else if(x==0)
{
system("cls");
menu();
break;
}
else
{
while(x!=1)
{
printf("\npress 1 to continue and press 0 for main menu(do not enter other value): ");
scanf("%d",&x);
if(x==1)
system("cls");
else if(x==0)
{
system("cls");
menu();
break;
}
}
}
if(m2==0)
{
printf("\n\nHoorah !!! Player 1 Won !!!");
delay(8000);
break;
}
if(m1==0)
{
printf("\n\nHoorah !!! Computer Won !!!");
delay(8000);
break;
}
}
}
void BST3()
{
int p1,p2,x,p1m=0,p2m=0,c=1;
int rand_num,dif1,dif2;
while(c3)
{
system("cls");
printf("\n\n\"Player 1\", Choose a number between (1-10): ");
scanf("%d",&p1);
while(1)
{
if(p1>=1&&p110)
break;
else
{
printf("\n\"Player 1\", please, choose a number between(1-10): ");
scanf("%d",&p1);
}
}
printf("\n\n\"Player 2\", Choose a number between (1-10): ");
scanf("%d",&p2);
while(1)
{
if(p2>=1&&p210)
break;
else
{
printf("\n\"Player 2\", please, choose a number between(1-10): ");
scanf("%d",&p2);
}
}
rand_num=rand()%10;
printf("\nThe dice says...");
delay(3000);
printf("\n\t%d\n",rand_num);
dif1=rand_num-p1;
dif2=rand_num-p2;
if(dif10)
dif1=dif1*(-1);
if(dif20)
dif2=dif2*(-1);
if(dif1dif2)
{
printf("\n\"Player 1\" has won this round. \n");
p1m++;
c++;
printf("\nScore Board:\t Player 1: %d\t Player 2: %d",p1m,p2m);
}
else if(dif1==dif2)
{
printf("\n\"No Player\" has won this round. \n");
c++;
printf("\nScore Board:\t Player 1: %d\t Player 2: %d",p1m,p2m);

}
else
{
printf("\n\"Player 2\" has won this round. \n");
p2m++;
c++;
printf("\nScore Board:\t Player 1: %d\t Player 2: %d",p1m,p2m);
}
delay(2000);
printf("\n\n\nNow, Press 1 to continue and press 0 to for main menu(do not enter other value): ");
scanf("%d",&x);
if(x==1)
system("cls");
else if(x==0)
{
system("cls");
menu();
break;
}
else
{
while(x!=1)
{
printf("\npress 1 to continue and press 0 for main menu(do not enter other value): ");
scanf("%d",&x);
if(x==1)
system("cls");
else if(x==0)
{
system("cls");
menu();
break;
}
}
}
}
if(p1m


This post first appeared on ProgramJoy.blogspot.com, please read the originial post: here

Share the post

The Dice Game in C-Language

×

Subscribe to Programjoy.blogspot.com

Get updates delivered right to your inbox!

Thank you for your subscription

×