Thread: break statement

  1. #1
    Registered User
    Join Date
    Oct 2002

    break statement

    sorry for asking such a simple question, but i'm not too comfortable using break statements outside of switch.

    Will the my break statement take me outside of the loop if the condition is true?

    bool PokerHand::is_Royal_flush(const vec& hand){
    	bool Same_suits = false;
    	Suit aSuit = hand[0].get_suit();
    	unsigned int i = 1;
    	while( i < hand.size() ){
    		if(hand[i].get_suit() != aSuit){
    			Same_suits = false;
    			Same_suits = true;
    	return Same_suits;
    Last edited by Motisa; 10-04-2002 at 01:51 PM.

  2. #2
    CS Author and Instructor
    Join Date
    Sep 2002
    You can also write the program without using a break in loops.

    Mr. c

  3. #3
    Registered User
    Join Date
    Oct 2002
    yes, but i think it is more efficent to break out of the loop once it finds one card that doesn't have the same suit as the other ones because it cannot be a royal flush.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Number to Word (Billions)
    By myphilosofi in forum C Programming
    Replies: 34
    Last Post: 02-04-2009, 02:09 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Break statement issues, how to return to start of loop?
    By brdiger31 in forum C++ Programming
    Replies: 3
    Last Post: 06-01-2007, 03:29 PM
  4. ascii rpg help
    By aaron11193 in forum C Programming
    Replies: 18
    Last Post: 10-29-2006, 01:45 AM
  5. syntax question
    By cyph1e in forum C Programming
    Replies: 19
    Last Post: 03-31-2006, 12:59 AM