Would you guys help me figure out what I am doing wrong. I am trying to write a dice program that rolls 2 dice and as long as there isn't a 2 or a 5 rolled it adds the dice and outputs the sum. I have it rolling the dice but it is ignoring my stipulation of a roll of 2 or 5 outputs your score is zero. Eventually I would like to turn this into a stuck in the mud game with multiple players but I am just taking baby steps first, however I would welcome suggestions on this as well.
#include <iostream>
#include <ctime>
#include <stdlib.h>
//contains (among other things) functions that deal with generating random numbers.
usingnamespace std;
int rollDice();
int main()
{
//cout << "enter direction number of player";
//char number_of_players;
//cin >> number_of_players;
srand((unsigned)time(0));
int sumOfDice = rollDice();
}
bool rolling = true;
int rollDice(){
int dice1 = 1 + rand()%6;
int dice2 = 1 + rand()%6;
int total = dice1 + dice2;
bool rolling = true;
if (dice1 || dice2 != 2 || 5 )
{
cout << "Player rolls " << dice1 << " and " << dice2 << " for a total of " << total << " You win!" << endl;}
else
{
cout << "Player rolls " << dice1 << " and " << dice2 << "your score is zero.\n";}while (rolling = true);
system ("pause");
return total;}