int i = 10, j = 20;
if (i < j)
{
Console.WriteLine("i is less than j");
}
if (i > j)
{
Console.WriteLine("i is greater than j");
}
string text = Console.ReadLine();
if(text == "yes")
{
Console.WriteLine("Correct!");
}
else
{
Console.WriteLine("Incorrect!");
}
if (/*condition here*/)
{
//code here
}
using System;
namespace DecisionMaking
{
class Program
{
static void Main(string[] args)
{
/* local variable definition */
int a = 10;
/* check the boolean condition using if statement */
if (a < 20)
{
/* if condition is true then print the following */
Console.WriteLine("a is less than " + a); //output: a is less than 20
}
Console.ReadLine();
}
}
}
if (condition)
{
print("Yes");
}
else
{
print("No");
}
if (statment) {
}
else if (statment) {
}
bool isMale = false;
bool isTall = false;
if (isMale && isTall)
{
Console.WriteLine("You are a tall male");
} else if (isMale && !isTall)
{
Console.WriteLine("You are a short male");
}else if (!isMale && isTall)
{
Console.WriteLine("You are not male but you are tall");
}else
{
Console.WriteLine("You are not male and you are not tall");
}
Console.ReadLine();
if (time <10)
{
Console.WriteLine("Good morning.");
}
else
{
Console.Writeline("Hatdog");
}
if (condition)
{
// block of code to be executed if the condition is True
}
else
{
// block of code to be executed if the condition is False
}
if (condition)
{
// block of code to be executed if the condition is True
}
string target = "www.testforranorex.com";
if (x == 0)
{
Console.WriteLine("hello world");
}
else
{
return 5;
}
if (boolean-expression)
{
// statements executed if boolean-expression is true
}
using System;
namespace Conditional
{
class IfStatement
{
public static void Main(string[] args)
{
int number = 2;
if (number < 5)
{
Console.WriteLine("{0} is less than 5", number);
}
Console.WriteLine("This statement is always executed.");
}
}
}
using System;
namespace Conditional
{
class IfElseStatement
{
public static void Main(string[] args)
{
int number = 12;
if (number < 5)
{
Console.WriteLine("{0} is less than 5", number);
}
else
{
Console.WriteLine("{0} is greater than or equal to 5", number);
}
Console.WriteLine("This statement is always executed.");
}
}
}
using System;
namespace Conditional
{
class IfElseIfStatement
{
public static void Main(string[] args)
{
int number = 12;
if (number < 5)
{
Console.WriteLine("{0} is less than 5", number);
}
else if (number > 5)
{
Console.WriteLine("{0} is greater than 5", number);
}
else
{
Console.WriteLine("{0} is equal to 5");
}
}
}
}
int a = 5;
int b = 10
if (a > b) //false
{
b = b - a;
}
else
{
a = a + b;
}