Pages

Write a program in which Print the Coming Position of Cricket Players Input by User by Using Linear Search/Denz array.

CODE: ( by Linear Search)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication25
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] batsmans = new string[]{"M Ali","Haeeb","Tahir","Usama","Butt","Afradi","Inzimam","Shoaib","Asad","Raja","Umer"};
            for (int j = 0; j < 11; j++)
            {
                    Console.Write("{0}\t",batsmans[j]);
            }
            Console.WriteLine("\n\nPlz Enter The Name of Batsman for His Coming Position");
            string name = Console.ReadLine();

            Console.WriteLine("At:\t");
            for (int j = 0; j < 11; j++)
            {
                if (batsmans[j] == name)
                {
                    Console.WriteLine(j+1);
                }

            }

        }
    }
}

OUTPUT:


No comments:

Post a Comment