I need a program that can simulate two dice rolling and then add the sum up together. You enter how many times you roll the dice and then it displays how many times your combined roll is a 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12.
Printable View
I need a program that can simulate two dice rolling and then add the sum up together. You enter how many times you roll the dice and then it displays how many times your combined roll is a 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12.
Sounds like homework...
What is the problem? Show the code you have so far
Edit:
Haha, I just saw the other post :D
I really wanted to be mean now, but ill be nice. Good luck :)
using namespace std;
int main(int argc, char *argv[])
{int dice1;
int dice2;
int dicesum;
dice1 = rand() % 6 + 1;
dice2 = rand() % 6 + 1;
dicesum = dice1 + dice2
cout << diesum;
return 0;
system("PAUSE");
return EXIT_SUCCESS;
There is a few tutorials on loops here, you should check them out. It might be just the thing you need :O
i dont know what a loop is
Thats why you should read the tutorial...
just do it for me
Here you go. But I will only do this once,ok?Quote:
just do it for me
Code:using namespace std;
int main(int argc, char *argv[])
{
int dice1;
int dice2;
loop noOfRolls = 3; // Will make it do it 3 times
int dicesum;
do noOfRolls(3)
(
dice1 = rand() % 6 + 1;
dice2 = rand() % 6 + 1;
dicesum = dice1 + dice2
cout << diesum;
) end noOfRolls(3)
return 0;
system("PAUSE");
return EXIT_SUCCESS;
}
Thanks a lot but it does not run
Maybe you should read the tutorial then, to see why?
where is it
under the tutorial section i guess?
cant find it
Wow catdieselpow, are you completely helpless? Your entire thread reeks of "I don't want to work, I don't want to think, you do everything for me."
My 3.5year old likes to play that game.
Me: "Pick up the Lego".
My son: "No, you help me" ("help" here means "you do it").
or
Me: "Get your T-shirt off for the bath"
My son: "You do it!".
We all started programming at some point, and I appreciate that it's difficult. But just like a 3.5year old needs to LEARN to get dressed, pick up toys, etc, someone who is in school or such trying to get excercises done needs to learn how to "think" programming. Not trying is not an option.
--
Mats