Pages

WRITE A PROGRAMME TO SAVE PLAYERS NAME AND SEARCH THEIR ARAY INDEX NUM: BY LINEAR SEARCHING METHOD

INPUT:

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

namespace Linear_Searching
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("\t\t\t\tPlayer Find");
            string[] player = new String[5];
            string search;
            for (int X = 0; X < 5; X++)
            {
                Console.WriteLine("Enter The Name Of Player {0}",X+1);
                player[X] = Console.ReadLine();

            }
            Console.WriteLine("Which Position U Want To Search");
            search = Console.ReadLine();
            for (int B = 0; B < 5; B++)
            {
                if (player[B] == search)
                {
                    Console.WriteLine("Player Position {0}", B + 1);
                }
            }
        }
    }
}



OUTPUT:


No comments:

Post a Comment