Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +917541905230, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec

Monday, July 6, 2020

Relational operator in C



Relational Operators in C
By Ahmad Irshad | C Programming Tutorial > Relational operaotrs in C

Relational operators are used to compare values of two similar expressions. It returns Boolean vlaues either true or false depending on relation. If the expression is true, it returns 1 and if the expression is false, it returns 0.

Relational operators are binary operators because they require two operands to operate. It is used in decision making and loops. We take decisions or execute some statements based on evaluated Boolean result.   

There are six relational operators in C, that compare two operands and return a boolean value either 0 (flse) or 1(true).

OperatorDescription
>Greater than
<Less than
>=Greater than or equal to
<=Less than or equal to
==Equals to
!=Not equal to
Let's have a look at the below example to understand each relational operators.

Suppose ab and c are three integer variables with initial values.

int a=10, b=5, c=10;

Relational operationsResultDescription
a > b110 > 5 is true, therefore returns 1
a < b010 < 5 is false, therefore returns 0
a >= c110 ≥ 10 is true, therefore returns 1
a <= b010 ≤ 5 is false, therefore returns 0
a == c110 = 10 is true, therefore returns 1
a != c010 ≠ 10 is false, therefore returns 0
Remember: please don't be confused assignment = operator with relational equals to ==operator. Both are different and their working mechanism are different. Beginners always makes this common mistake of using = in place of ==. Hence use these with cautious.




Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +966532621401, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec

Help others by sharing this page.

Ahmad Irshad

Author & Editor

I love blogging, teaching, learning computer science and sharing it to others. I've written and develped this site so that students may learn computer science related tutorials eaisly. MCA / MCITP

0 Comments:

Post a Comment

Please don't enter any spam link in the comment box.


Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +966532621401, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec
Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec
Contact Us