if, if-else, if-else if
If Statements
If StatementsIf something is true/false, the next is done.
int marks = 77;
if (marks > 50)
{
Console.WriteLine("PASS");
}If
marksgreater than 50, then pass. Nothing is done in any other scenario.
If-else Statements
If-else StatementsIf true/false do one thing, otherwise do something else.
int marks = 77;
if (marks > 50)
{
Console.WriteLine("PASS");
}
else
{
Console.WriteLine("FAIL");
}If-else if Statements
If-else if StatementsHandles multiple conditional statements
Last updated