Syntax for Multiple - If


        if (condition)
        {
                   Statements
                  .
                  .
        }
        if (condition)
        {
                  Statement
                  .
                  .
        }
        .
        .



Example :-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CABasics
{
    class IFExample6
    {
        static void Main(string[] args)
        {
            int N;
            Console.WriteLine("Enter any Number either 1 or 2 or 3");
            N = Convert.ToInt32(Console.ReadLine());
            if (N == 1)
            {
                Console.WriteLine("You have Entered 1");

            }

            if (N == 2)
            {
                Console.WriteLine("You have Entered 2");
            }
            if (N == 3)
            {
                Console.WriteLine("You have Entered 3");
            }
            Console.ReadLine();

        }
    }
}


































Output:-










No comments:

Post a Comment