Ticker

6/recent/ticker-posts

C Language (Relational Operators)

RELATIONAL OPERATORS IN C

Relational operators are used to check/test the relationship between two operand, if the relation true then relation operator return 1, if the relation false then relational operator return 0.





RELATIONAL OPERATORS SYMBOLIC TABLE
OPERATOR
MEANING OF OPERATOR
==
Equal to
!=
Not equal to
> 
Greater than
>=
Greater than or equal to
< 
Less than
<=
Less than or equal to


RELATIONAL OPERATOR EXAMPLES

// Equal to operator example
void main()
{
clrscr();
int n=4;
if(n%2 == 0)
printf("Even number");

else
printf("Odd number");
getch();
}


// Not equal to operator example

void main()
{
clrscr();
int n=7;
if(n%2 != 0)
printf("Odd number");

else
printf("Even number");
getch();
}


// Greater than operator example

void main()
{
clrscr();
int a=6, b=3;
if(a > b)
printf("a is greater than b");

else
printf("b greater than a");
getch();
}


// Less than operator example

void main()
{
clrscr();
int a=4, b=3;
if(a < b)
printf("a is less than b");

else
printf("b is less than a");
getch();
}


// Greater than or equal to operator example

void main()
{
clrscr();
int m=33;
if(m >= 33)
printf("Result is pass");

else
printf("Result is fail");
getch();
}













Post a Comment

0 Comments