question related past question on how to use not equal to for two numbers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DEAbhishekBUG
    New Member
    • Feb 2010
    • 3

    question related past question on how to use not equal to for two numbers

    sir i am a student and i always want to learn more
    i replied for the question -how-do-i-say-not-equal-more-than-one-number
    my reply was
    1> if given variable is either not equal to 1 or 2 you need to code:
    if((variable !=1)||(variable !=2)) // ' | '(just above enter key ) :is called as pipeline operator and is logical equivalent of " or "

    2>if given variable is not eqal to both 1 & 2 :
    if((variable !=1)&&(variable !=2)) // ' & ' :is and operator

    i want to know in what situation or circumstance this is not useful so please help me learn basics of this language
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    1) It is not useful in any situation, or put it another way there is no situation in which this expression is useful.

    Calculate the logic on paper assign a value to variable and calculate the value of

    (variable !=1)||(variable !=2)

    you will quickly find that it always has the value true.

    2) This is a useful and common construct, however the "not useful" comment you are referring to was only referring to the logic in example 1.

    Comment

    • mush1578
      New Member
      • Feb 2010
      • 15

      #3
      1: means if any one these two variable not equal then do that

      2: use for that if both these variable are not equl then do that

      Comment

      • DEAbhishekBUG
        New Member
        • Feb 2010
        • 3

        #4
        thank for your response i got the point

        Comment

        Working...