Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Successfully reported this slideshow.

Like this presentation? Why not share!

- Object oriented techniques by LearnNowOnline 7228 views
- Lecture21 categoriesof userdefinedf... by eShikshak 2200 views
- Lecture15 comparisonoftheloopcontro... by eShikshak 1247 views
- Html phrase tags by eShikshak 1303 views
- Mesics lecture 5 input – output i... by eShikshak 2038 views
- Mesics lecture 3 c – constants an... by eShikshak 1444 views

745 views

Published on

relational and logical operators

No Downloads

Total views

745

On SlideShare

0

From Embeds

0

Number of Embeds

1

Shares

0

Downloads

34

Comments

0

Likes

1

No embeds

No notes for slide

- 1. Relational and Logical Operators www.eshikshak.co.in
- 2. Relational Operators● Compare two values Result 1 True 0 False● Six Operators, No space between the operator Operator Meaning == Equal to != Not Equal to < Less than > Greater than <= Less than or equal to >= Greater than or equal to www.eshikshak. co.in
- 3. Relational Operators● If arithmetic expression on either side of relational operator, than arithmetic expression will be evaluated first and then the results are compared.● All of these operators are known as binary operator, as they required two expressions as operands.● They are used with condition statements www.eshikshak. co.in
- 4. Example● if ( value == 0 )●{● printf (“The value you entered was zero.n”) ;● printf(“Please try again.n”) ;●}● else●{● printf (“Value = %d.n”, value) ;●} www.eshikshak. co.in
- 5. Relational OperatorsExpression Meaning Result5 == 3 5 is equal to 3 05 != 3 5 is not equal to 3 15>3 5 is greater than 3 15<3 5 is less than 3 0 5 is greater than or equal to5 >= 3 1 35 <= 3 5 is less than or equal to 3 0 www.eshikshak. co.in
- 6. Logical Operator● Sometimes we need to test multiple conditions in order to make a decision.● Logical operators are used for combining simple conditions to make complex conditions. www.eshikshak. co.in
- 7. Logical OperatorOperator Meaning&& AND|| OR! NOT www.eshikshak. co.in
- 8. && (Logical AND)● (expression1 && expression2)● expression1 expression2 Overall Result True True True (non-zero) (non-zero) (non-zero) True False False (non-zero) (zero) (zero) False True False (zero) (non-zero) (zero) False False False (zero) (zero) (zero) www.eshikshak. co.in
- 9. && (Logical AND) Expression ResultA = ( 5 != 4 ) && ( 3 + 6 == 9 ) A=1A = ( 5 == 4 ) && ( 3 + 6 == 9 ) A=0A = ( 5 == 5 ) && ( 3 + 5 == 9 ) A=0A = ( 5 == 4 ) && ( 3 + 5 == 9 ) A=0 www.eshikshak. co.in
- 10. || (Logical OR)● (expression1 || expression2) expression1 expression2 Overall Result True True True (non-zero) (non-zero) (non-zero) True False True (non-zero) (zero) (non-zero) False True True (zero) (non-zero) (non-zero) False False False (zero) (zero) (zero) www.eshikshak. co.in
- 11. || (Logical OR) Expression ResultA = ( 5 != 4 ) || ( 3 + 6 == 9 ) A=1A = ( 5 == 4 ) || ( 3 + 6 == 9 ) A=0A = ( 5 == 5 ) || ( 3 + 5 == 9 ) A=0A = ( 5 == 4 ) || ( 3 + 5 == 9 ) A=1 www.eshikshak. co.in
- 12. www.eshikshak.co.in

No public clipboards found for this slide

Be the first to comment