Tutorial Addendum On C# - Allotment A - Analytic Expressions and Codicillary Statements

android appcolt kidsgamesios wordgamesios
 31 December 18:00   

    



    



    

Logical Expressions

    



    

Logical expression is a way of cogent a analytic condition, aloft which assertive parts

    

of the program beheading breeze can be altered. For example, a appliance abundance wants the

    

following supply accuse in its balance program : if the absolute bulk of an adjustment is

    

less than $200.00, supply is answerable as $25.00; if the bulk is greater than or

    

equal to $200.00, supply is free. Actuality "amount is beneath than $200.00" is a analytic condition

    

that needs to be entered in C# program as a analytic express.

    



    

The alotof simplest analytic altitude involves relational operators:

    



        

  • ">": Greater than


  •     

  • "<": Beneath than


  •     

  • ">=": Greater than or equal


  •     

  • "<=": Beneath than or equal


  •     

  • "==": Equal


  •     

  • "!=": Not equal


  •     



    



    

A relational operation can be entered into C# programs as a analytic announcement with the

    

following syntax:

    



    

logical_expression:

    

arithmetic_expression relational_operator arithmetic_express

    



    

After evaluation, a analytic announcement will aftermath a boolean value, true or false.

    



    

Examples of analytic expressions are:

    



        

  • "1 < 2":

        

    This is a simple analytic expression. The consistent amount is true.

        



  •     

  • "1 > 2":

        

    This is aswell a simple analytic expression. The consistent amount is false.

        



  •     

  • "quantity * amount < 200.00":

        

    The addition announcement "quantity * price" will be evaluated first. Its result

        

    will be then compared with 200.00. The consistent amount is true or false, depending on

        

    the consistent amount of addition expression.

        



  •     

  • "exam_score == 100":

        

    If the amount in exam_score is according to 100, the consistent amount will be true.

        

    Otherwise, it will be false.

        



  •     



    



    

"if" Statements

    



    

The alotof frequently acclimated codicillary account is the "if" statement, which has the following

    

syntax:

    



    

if statement:

    

if (logical_expression) {

    

embeded_statements

    

}

    



    



    

When an "if" account is encountered in the excution flow, the analytic announcement will be

    

evaluated first. If the consistent amount is true, the embeded statements that are amid in braces

    

immediately afterwards the analytic announcement will be executed. If the consistent amount is false,

    

those embeded statements will be skipped.

    



    

An "if" account can aswell accept an "else" clause, which will accommodate a block of embeded statements

    

to be accomplished alone if the analytic announcement is evaluated to false. Actuality is the syntax

    

of "if else" statement:

    



    

if statement:

    

if (logical_expression) {

    

embeded_statements

    

} abroad {

    

embeded_statements

    

}

    



    



    

In the "else" clause, we could accept addition analytic action to separate the beheading in

    

two added ways:

    



    

if statement:

    

if (logical_expression) {

    

embeded_statements

    

} abroad if (another_logical_expression) {

    

embeded_statements

    

} abroad {

    

embeded_statements

    

}

    



    



    

 


Tags: simple, program, statements, value, greater, delivery, statement, false

 logical, expression, statements, embeded, value, statement, resulting, false, equal, arithmetic, greater, expressions, conditional, program, delivery, relational, , logical expression, embeded statements, resulting value, expression will, arithmetic expression, greater than, logical expressions, logical expression will, simple logical expression, < less than,

Share Tutorial Addendum On C# - Allotment A - Analytic Expressions and Codicillary Statements:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Computers & Technology  -  c-sharp