Posts

Showing posts with the label #C# #ControlStatements

C# Control Statements

  The flow of program control is specified by control statements in C#. It includes the following − 1. if statement An if statement consists of a Boolean expression followed by one or more statements. The following is the syntax − if ( boolean_expression ) {     /* statement(s) will execute if the boolean expression is true */ } 2. if-else statement An if statement can be followed by an optional else statement, which executes when the Boolean expression is false. The following is the syntax − if ( boolean_expression ) {     /* statement(s) will execute if the boolean expression is true */ } else {     /* statement(s) will execute if the boolean expression is false */ } 3. for loop It executes a sequence of statements multiple times and abbreviates the code that manages the loop variable. The following is the syntax − for ( init ; condition ; increment ) {    statement ( s ); } 4. while loop It repeats a statement or a group o...