Execute a block of code based on the result of an expresssion that utilizes relational or logical (boolean) operators
If Statement:
int anint = 1;
if (anint >= 0)
{
// Execute some code
}
If Else Statement:
int anint = 1;
if (anint >= 0)
{
// Excute some code
}
else
{
// Execute some other code
}
If, Else If, Else:
int anint = 1;
if (anint >= 0)
{
// Execute some code
}
else if (anint < -1)
{
// Execute some other code
}
else
{
// Execute this code if none of the other conditions are true
}
You can use the boolean operations to use boolean logic on multiple expressions.
int anint = 1;
int anotherint = 2;
if (anint > 0 && anotherint <= 2)
{
// Execute some code
}