usingSystem;namespaceDecisionMaking{classProgram{staticvoidMain(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();}}}
bool condition =true;if(condition)var t ="The condition its true";elsevar f ="The condition its false";// We dont need to use the '{' because it's just 1 change
bool isMale =false;bool isTall =false;if(isMale && isTall){
Console.WriteLine("You are a tall male");}elseif(isMale &&!isTall){
Console.WriteLine("You are a short male");}elseif(!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(true)// if something is true or false{//code}elseif(false)// something else if something is true or false{//code}else// if something is true or not{//code}
usingSystem;namespaceConditional{classIfStatement{publicstaticvoidMain(string[] args){int number =2;if(number <5){
Console.WriteLine("{0} is less than 5", number);}
Console.WriteLine("This statement is always executed.");}}}
usingSystem;namespaceConditional{classIfElseIfStatement{publicstaticvoidMain(string[] args){int number =12;if(number <5){
Console.WriteLine("{0} is less than 5", number);}elseif(number >5){
Console.WriteLine("{0} is greater than 5", number);}else{
Console.WriteLine("{0} is equal to 5");}}}}