Thread: About if statement

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    96

    About if statement

    Hello,

    I have a question,is it true that we can't use "break" statement with "if statment"?

    Can "break" statement be only used with "for" ,"while" and "do while" loops?

    thanks

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Yes, you cannot use a break statement to break out of an if statement. You can only use it with iteration statements and switch statements.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    733
    Quote Originally Posted by student111 View Post
    Can "break" statement be only used with "for" ,"while" and "do while" loops?
    And inside a switch statement.

  4. #4
    Registered User
    Join Date
    Nov 2011
    Posts
    96
    thanks for the reply,

    Can we use "if statement" inside an "if statement"?

  5. #5
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    733
    Yes, it is called nesting. But these questions can easily be answered by the tool called Google.

  6. #6
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    these questions can easily be answered by the tool called Google.
    Yes and the results will contain links to pages like these, with the related information on. Google is not the source of the information is it. So if nobody could be bothered answering more clearly ever then there would be no pages to link to.
    Last edited by rogster001; 11-17-2013 at 05:33 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  7. #7
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    733
    Quote Originally Posted by rogster001 View Post
    Yes and the results will contain links to pages like these, with the related information on. Google is not the source of the information is it. So if nobody could be bothered answering more clearly ever then there would be no pages to link to.
    What the hell are you talking about? My second result was:

    C++ nested if statements

    And I entered "if inside if" not "nested if".

  8. #8
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    was just saying.. sometimes we refer people to google, which already contains answer links to what they are looking for, but then obviously those search results are what forums posts and articles provide.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what -> mean in if statement?
    By byebyebyezzz in forum C++ Programming
    Replies: 4
    Last Post: 07-24-2011, 11:34 AM
  2. Statement inside a statement.
    By JOZZY& Wakko in forum C Programming
    Replies: 15
    Last Post: 11-05-2009, 03:18 PM
  3. if or statement help plz
    By dezz101 in forum C Programming
    Replies: 2
    Last Post: 04-13-2008, 05:53 AM
  4. org statement
    By yankees2008 in forum C Programming
    Replies: 7
    Last Post: 03-31-2008, 03:41 PM
  5. if statement
    By xlordt in forum C Programming
    Replies: 7
    Last Post: 04-11-2003, 08:06 AM