nested if-else statement in C#

 

For Example: Write a program to demonstrate use of nested if-else statement.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace ConsoleApplication1

{

class Program

    {

static void Main(string[] args)

        {

int a,b,c;

Console.WriteLine("Enter value for A");

            a = Convert.ToInt32(System.Console.ReadLine());

Console.WriteLine("Enter value for B");

            b = Convert.ToInt32(System.Console.ReadLine());

Console.WriteLine("Enter value for C");

            c = Convert.ToInt32(System.Console.ReadLine());

if (a>b&&a>b)

            {

Console.WriteLine("A is largest");

Console.ReadLine();

            }

elseif (b > a && b > c)

            {

Console.WriteLine("B is Largest");

Console.ReadLine();

            }

else

            {

Console.WriteLine("C is Largest");

Console.ReadLine();

            }

 

        }

    }

}

Output:

Comments

Popular posts from this blog

simple program C#

Regular Expression Validator Control in asp.net

two dimension array in C#