Create a program that will provide the information and discussion of the conditional
statements available in C# Programming Language.
Sample output:
Conditional Statements Menu
a. if ( )
b. if ( ) - else
c. nested if ( )
d. sequences of if ( ) - else - if ( ) - else - ...
e. switch ( ) – case
please select your choice: a
Conditional Statement “if”
The main format of the conditional statements if is as follows:
if (Boolean expression)
{
Body of the conditional statement;
}
It includes: if-clause, Boolean expression and body of the conditional
statement.
The Boolean expression can be a Boolean variable or Boolean logical
expression. Boolean expressions cannot be integer (unlike other
programming languages like C and C++).
using System;
namespace if_else
{
internal class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Conditional Statements Menu");
Console.WriteLine("[a] if( )");
Console.WriteLine("[b] if( )-else");
Console.WriteLine("[c] nested if( )");
Console.WriteLine("[d] sequences of if( ) - else - if( ) - else");
Console.WriteLine("[e] switch( ) - case");
Console.Write("\n Please select your choice: ");
string str = Console.ReadLine();
Console.Write($"You are selected [{str}]");
Console.ReadLine();
}
}
}
Comments
Leave a comment