Comparision Operators in Expression [ If Statement ]

May 14, 2010 No Comments » Hits : 15







Example 1 : Illustration of Indirect or Invisible If


More Theory :

Click Here : Indirect If Statement

We have seen basic concept about “Indirect Use of If Statement” . Now we are focusing on more and more short tutorials before solving MCQ’s .

#include<stdio.h>void main(){int a = 40 , b = 30 ,c;c = !(a>=0) >= 0printf("%d",c);}

Output :

1

How ?

  1. While Solving such a Long expression , First Scan Expression from Left to Right .
  2. Solve Expression bounded in Pair of ( ) .

Step 1 : 

  1. Always Solve Bracket First
c = !(a>=0) >= 0

Step 2 :

  1. a>=0 is True
  2. So Replace “a>=0″ by 1
c = !1 >= 0

Step 3 : 

  1. NOT Operator has Higher Priority Than >= Operator .
  2. !1 = 0 
  3. Replace “!1″  by “0″
c = 0 >= 0

Step 4 :

  1. Obviously 0 >= 0 is True Condition 
  2. Replace Whole Expression by 1 
c = 1

Thus C = 1


Related Articles:

Leave A Response