473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Dice Rolling

I neeed help with detecting the points



Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <iostream.h>
  5.  
  6. int rollDice()
  7. {
  8.     return ((rand() % 6) + 1);
  9. }
  10.  
  11. int main()
  12. {
  13. char C='c';
  14.  
  15. do
  16. {
  17.   int dice1=rollDice();
  18.   int dice2=rollDice();
  19.   int point = dice1+dice2;
  20.  
  21.  printf("\n You rolled: %d, %d, %d", dice1, dice2, point);
  22.  
  23.     if((point == 7) || (point == 11))
  24.     {
  25.         printf("\n You Win ");
  26.         printf("\n press r to roll again ");
  27.         cin>>C;
  28.     }
  29. else
  30.     {
  31.             if((point == 3) || (point == 2) || (point == 12))
  32.             {
  33.                  printf("\n You Lose ");
  34.                 printf("\n press r to roll again ");
  35.                 cin>>C;
  36.             }
  37.  
  38.     else 
  39.     {
  40.     printf("\n Press r to roll ");
  41.     cin >> C;
  42.  
  43.      int temp = rollDice() + rollDice();
  44.      if(temp == point)
  45.      {
  46.        printf("\n You Win! ");
  47.      }
  48.     else 
  49.     {
  50.       if(temp == 7)
  51.       {
  52.       temp = rollDice() + rollDice();
  53.       printf("\n You Lose ");
  54.       }
  55.             /**    while(temp!=7)
  56.                 {
  57.                       temp = rollDice() + rollDice();
  58.                 }
  59.                 //    printf("\n You Lose ");**/    
  60.             }
  61.         }
  62.     }
  63. }
  64. while(C!='e');
  65. return 0;
  66. }
Oct 3 '07 #1
1 1408
Ganon11
3,652 Expert 2GB
What exactly do you mean by 'detecting the points'?
Oct 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: lawentzel | last post by:
I am new to PHP and am an avid RPG gamer. I am looking to use PhpMyChat to be able to game with friends all over the US. With that having been said, PhpMyChat seems to offer a lot of what I am...
101
by: Elijah Cardon | last post by:
Let's say I have m dice having n sides, such that n^m is not going to bust int as a datatype. With m=4 and n=6, an outcome might be {2, 5, 1, 2}. What is a good way to represent this in c so that...
17
by: Jose Durazo | last post by:
Hello, I'm doing an exercise to simulate rolling a pair of dice 36,000 times, then count and display how many times the simulation rolls each possible sum. For some reason each time I run my...
1
by: lenest | last post by:
I need help writing a program.... You are to write a python program to accomplish the following: a.. Play a dice game of Craps using a random number generator to simulate the roll of the...
4
by: vegtard | last post by:
simple question. is it possible to write a script that rolls a six sided dice? if this is possible, is it possible to tell it to roll the six sided dice 4 times and ignore the dice that rolled...
38
by: d0ugg | last post by:
I'm writing a program that will have to roll the dice A and dice B one million times, and calculate the percentage of times that the dies will be equal. I'm having trouble to figure out how the...
2
by: sunnydude | last post by:
Anybody know how to write a 3 dice rolling program like this Sample output Welcome to the dice roller! First of all, please enter a seed for the random number generator. This should be a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.