One In C # If the Boolean expression is When the above code is compiled and executed, it produces the following results:
if
a statement consists of a Boolean expression followed by one or more statements. 1.11.1. Grammar #
if
syntax of the statement:if(boolean_expression)
{
/* The statement to be executed if the Boolean expression is true */
}
true
, the code block within the
if
statement will be executed. If the Boolean expression is
false
, the first set of code (after closed parentheses) after the end of the
if
statement will be executed. 1.11.2. Flow chart #

1.11.3. Example #
using System;
namespace DecisionMaking
{
class Program
{
static void Main(string[] args)
{
/* Definition of Local Variables */
int a = 10;
/* Check Boolean conditions using if statements */
if (a < 20)
{
/* If the condition is true, output the following statement */
Console.WriteLine("A less than 20");
}
Console.WriteLine("The value of a is {0}", a);
Console.ReadLine();
}
}
}
A less than 20
The value of a is 10