C comparison operators in expression



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>
int main()
{
int a = 40;
int b = 30;
int c;
c = !(a>=0) >= 0;
printf("%d",c);
return(0);
}

Output :

1

How to Make use of Comparison Statement inside If Statement :

  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