class Program
    {
        static void Main(string[] args)
        {
            char[] ch = new char[30];
            string str;
            int count = 1, i, j;
            Console.WriteLine("Enter the string ");
            str = Console.ReadLine();
            int length = str.Length;
            for (i = 0; i < length; i++)
            {
                ch[i] = str[i];
            }
            for (i = 1; i < length; i++)
            {
                for (j = 0; j < i; j++)
                {
                    if (ch[i] == ch[j])
                        break;
                }
                if (j == i)
                {
                    ch[count] = ch[i];
                    count++;
                }
            }
            Console.WriteLine("After removing the duplicat character");
            {
                for (i = 0; i < count; i++)
                {
                    Console.Write(ch[i]);
                }
            }
            Console.WriteLine();
            Console.ReadLine();
        }
    }
 
No comments:
Post a Comment