Simple dice game ..or boolean operator not working right

This is a discussion on Simple dice game ..or boolean operator not working right within the C Programming forums, part of the General Programming Boards category; I'm making a simple roll the dice game that displays your the winner if you roll a 7 or 11. ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    23

    Simple dice game ..or boolean operator not working right

    I'm making a simple roll the dice game that displays your the winner if you roll a 7 or 11.
    But my 'OR' operator doesn't seem to be working.
    It always displays your the winner regardless the roll of the dice.
    If I remove the || and 11 it works fine.
    This is kinda driving me nuts, it should be real simple

    Code:
    #include <stdio.h>
    #include <ctype.h>
    #include <time.h>
    #include <stdlib.h>
    
    
    int main(int argc, char** argv)
    {	
    	int dice_1 = 0;
    	int dice_2 = 0;
    	int rollDice = 0;
    	time_t t;
    	srand(time(&t));
    	
    		
    	dice_1 = (rand() % 6) + 1;
    	dice_2 = (rand() % 6) + 1;
    	rollDice = dice_1 + dice_2;
    	
    	if (rollDice == 7 || 11){
    	printf("You lucky bastard! You rolled a %d\n", rollDice);
    	}
    	else {
    	printf("Your roll was %d ,you lose try agian.\n", rollDice);
    	}
    		
    	
    	
    	return 0;
    }

  2. #2
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    if(rollDice == 7 || rollDice == 11)

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    23
    DOH!

    I new it was something simple.
    thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [freefps]Tactical Assault coders needed
    By Sickmind in forum Projects and Job Recruitment
    Replies: 4
    Last Post: 05-07-2010, 06:06 PM
  2. Event driven game engine
    By abachler in forum Game Programming
    Replies: 9
    Last Post: 12-01-2009, 06:03 AM
  3. Simple Network Game Programing...
    By IndioDoido in forum Networking/Device Communication
    Replies: 4
    Last Post: 11-07-2007, 06:56 AM
  4. Simple game over network
    By Tommo in forum Networking/Device Communication
    Replies: 2
    Last Post: 10-12-2007, 04:07 PM
  5. Problems with a simple console game
    By DZeek in forum C++ Programming
    Replies: 9
    Last Post: 03-06-2005, 02:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21