Syntax of
if control structure in C
Relational Operators in C
Operator

Meaning

Example

Value of the
expression

<

less than

age < 30

>

greater than

height > 6.2

<=

less than or equal to

taxable <= 20000

Value is 0
(Zero) if
expression is
false

>=

greater than or equal to

temperature >= 98.6

==

equal to

marks == 100

!=

not equal to

number != 250

Value is 1 (one)
if expression is
True
if(x<y)
{
……….
……….
}
if(‘a’<‘P’)
{
……….
……….
}

If x contains 5 and y contains 10
then value of the expression is
1 and condition is true
If x contains 10 and y contains 4
then value of the expression is
0 and condition is false

As ASCII value of A is 97 and ASCII
value of P is 80 the expression is
false and value of the expression
is 0
If block
if(-5)
{
……….
……….
}

Valid condition. -5 is a truth
value and is non zero. So value
of the expression is 1 and
statement is true!

if(x)
{
……….
……….
}

If x contains any non zero value
the expression is true and value of
the expression is 1.
If x contains zero, value of the
expression is 0 and statement is
false

If control structure in c lnaguage

  • 1.
    Syntax of if controlstructure in C
  • 2.
    Relational Operators inC Operator Meaning Example Value of the expression < less than age < 30 > greater than height > 6.2 <= less than or equal to taxable <= 20000 Value is 0 (Zero) if expression is false >= greater than or equal to temperature >= 98.6 == equal to marks == 100 != not equal to number != 250 Value is 1 (one) if expression is True
  • 3.
    if(x<y) { ………. ………. } if(‘a’<‘P’) { ………. ………. } If x contains5 and y contains 10 then value of the expression is 1 and condition is true If x contains 10 and y contains 4 then value of the expression is 0 and condition is false As ASCII value of A is 97 and ASCII value of P is 80 the expression is false and value of the expression is 0 If block
  • 4.
    if(-5) { ………. ………. } Valid condition. -5is a truth value and is non zero. So value of the expression is 1 and statement is true! if(x) { ………. ………. } If x contains any non zero value the expression is true and value of the expression is 1. If x contains zero, value of the expression is 0 and statement is false