Selection Selection allows you to choose between two or more alternatives. In C this means that the course of your executing program will depend on the result of an expression. true (any other value but zero) false (zero) expression Statement 2 Statement 1 Logical Flow Selection
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Selection allows you to choose between two or more alternatives. In C this means that the course of your executing program will depend on the result of an expression.
Logical data in C - C recognizes zero as a false value and any other nonzero value is considered true.
Logical Operators - logical operators form conditions or logical expressions.
Thenot operator ( ! ) changes a true value (nonzero ) to false ( zero ) and a false value ( zero ) to true (one ).
The andoperator ( && ) is a binary operator with four distinct possible combinations of values in its operands.
The or operator ( || ) is a binary operator with four distinct combinations of values in its operands.
Short-circuit evaluation - C will stop evaluation when it knows for sure what the final result will be.
false && ( anything )
true || ( anything )
after the first operand is evaluated and found to be false and the operator is the and operator ( && ) the second operand will not be evaluated ( this could cause unexpected results if the second operand has side effects )
Relational Operators - Relational operators support logical relations. They are all binary operators that accept two operands and compare them. The result is logical data, that is, it is always a zero or one.
belong to the
not to the
else is null
The compiler pairs
this if and else!