Thread: Quick question

  1. #1
    Registered User
    Join Date
    Sep 2013

    Quick question

    what does this mean?

    if(somenumber == 0)
        blah blah
        blah blah
    else if(somenumber%2)
        blah blah
    what does the ! in the parenthesis mean? i thought if statement should compare 2 variables.
    Last edited by Kevin Nguyen; 10-24-2013 at 08:10 PM.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007

  3. #3
    11DE784A SirPrattlepod's Avatar
    Join Date
    Aug 2013
    The general form of the if statement is

    if (expression)

    Note that expression need not compare two values, the only thing that is checked is expression (or more correctly the result of the expression). If the expression evaluates to "true" (not zero) then statement is executed. So although expression might be used to compare two or more values it doesn't have to do so. The expression may even be a constant, e.g. if (1) statement;

  4. #4
    Registered User
    Join Date
    Oct 2013
    ! means not. Like if (True) and if(!true). Hope you get it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick question
    By zach48191 in forum C Programming
    Replies: 7
    Last Post: 10-21-2011, 12:05 AM
  2. quick if question
    By thanatos1 in forum C# Programming
    Replies: 4
    Last Post: 07-04-2009, 07:11 AM
  3. One quick question...
    By Kross7 in forum C++ Programming
    Replies: 10
    Last Post: 04-13-2007, 09:50 PM
  4. quick question
    By Mshock in forum C Programming
    Replies: 3
    Last Post: 04-24-2006, 04:01 AM
  5. Quick H/W question...
    By djz3r0 in forum C++ Programming
    Replies: 15
    Last Post: 09-12-2004, 08:36 PM