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();
}
{
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();
}
No comments:
Post a Comment