Program for count a total no of duplicate element in given dynamic array.

Hi,
This program is for count a total no of duplicate element in given array values. 
Hope this is helpful for you.

   class Program
    {
        static void Main(string[] args)
        {
            int input = 0;
            int[] arrayvalue = new int[] { };
            int[] Temp_array = new int[] { };
            int[] duplicate_array = new int[] { };
            Console.Write("Enter no of object that you want to display:-");
            input = Convert.ToInt32(Console.ReadLine());
            arrayvalue = new int[input];
            Temp_array = new int[input];
            duplicate_array = new int[input];
            int DuplicateCount = 0;
            for (int i = 0; i <= arrayvalue.Length - 1; i++)
            {
                Console.Write("Element at {0} - ", i);
                arrayvalue[i] = Convert.ToInt32(Console.ReadLine());
            }
            for (int k = 0; k <= arrayvalue.Length - 1; k++)
            {
                int count = 0;
                if(Temp_array.Length == 0 || !Temp_array.Contains(arrayvalue[k]))
                {
                    Temp_array[k] = arrayvalue[k];
                }
                else
                {
                    duplicate_array[k] = arrayvalue[k];
                }

            }
            Array.Clear(Temp_array,0,input);//Clear array
            Console.WriteLine("----------------------");
            for (int j =0;j<duplicate_array.Count();j++)
            {
                //get list of duplicate element in an array.
                if (duplicate_array[j] != 0 && !Temp_array.Contains(duplicate_array[j]))
                {
                    Temp_array[j] = duplicate_array[j];
                    DuplicateCount++;
                }
            }
            Console.WriteLine("The total no of duplicate element is - {0}:",DuplicateCount);
            Console.ReadLine();
        }
    }

 For Ex input :1,2,1,2,1
 output:The total no of duplicate element is 2.

Program for save values in dynamic array and display it into reverse order.

Hello,
This is program is for generate dynamic array and store values into that array.after that it will display you in reverse order without using inbuilt function.
Hope it will useful for you.

//Array.
    class Program
    {
        static void Main(string[] args)
        {
            int input = 0;
            int[] arrayvalue = new int[] { };

            Console.Write("Enter no of object that you want to display:-");
            input = Convert.ToInt32(Console.ReadLine());
            arrayvalue = new int[input];
            for (int i = 0; i <= arrayvalue.Length - 1; i++)
            {
                Console.Write("Element at {0} - ", i);
                arrayvalue[i] = Convert.ToInt32(Console.ReadLine());
            }
            //Display values that you have inserted
            for (int k = 0; k <= arrayvalue.Length - 1; k++)
            {
                Console.WriteLine(arrayvalue[k]);
            }
            //Display values in reverse order that you have inserted
            Console.WriteLine("Reverse values of given array");
            for(int j = arrayvalue.Length - 1; j >= 0; j--)
            {
                Console.WriteLine(arrayvalue[j]);
            }
            Console.ReadLine();
        }
    }

Program for get total no of alphabets,digits and special char from given string

Hello,

Below program is for get total count of alphabets,digits and special char from given string.
Hope it will be useful for you.

 class Program
    {
        static void Main(string[] args)
        {
            string s = "";
            int alphacount = 0, digitcount = 0, specialcount = 0;
            Console.WriteLine("Enter string");
            s = Console.ReadLine();
            foreach (int i in s)
            {

                if ((i >= 65 && i <= 90) || (i >= 97 && i <= 122))
                    alphacount++;
                else if (i >= 48 && i <= 57)
                    digitcount++;
                else
                    specialcount++;
            }
            Console.WriteLine("Total no of Alphabets:"+""+ alphacount);
            Console.WriteLine("Total no of Digits:" + "" + digitcount);
            Console.WriteLine("Total no of Specialchar:" + "" + specialcount);
            Console.ReadLine();
        }
    }

  For ex input:goswami himanshu15@gmail.com :
  Output:Total no of Alphabets:23
               Total no of Digits:2
               Total no of Specialchar:3

    

Program for check that given string is palindrome or not.

Hello,
Below program is for check whether given string is palindrome or not.means that string that you have provide and reverse of that string should match.
Hope you will enjoy it.

 //check given string is palindrome or not.
    class Program
    {
        static void Main(string[] args)
        {
            string s = "";
            Console.WriteLine("Enter string");
            s = Console.ReadLine();
            string final = "";
            for (int i = s.Count()-1; i >= 0; i--)
            {
               final += s[i];
            }
            if (final == s)
            {
                Console.WriteLine("Given string is palindrome");
                Console.Write(final);
            }
            else
            {
                Console.WriteLine("Given string is not palindrome");
                Console.Write(final);

            }
            Console.ReadLine();
        }
    }

   if input="madam"
   output:"Given string is palindrome".

Display inserted string in reverse without using inbuilt function.

Hello,

Below program is for display inserted string in reverse. Hope you will enjoy.

//Display string in Reverse
    class Program
    {
        static void Main(string[] args)
        {
            string s = "";
            Console.WriteLine("Enter string");
            s = Console.ReadLine();
            string final = "";
            for (int i = s.Count()-1; i >= 0; i--)
            {
               final += s[i];
            }
            Console.Write(final);
            Console.ReadLine();
        }
    }

   If input="Hello Program"
   Output: margorP olleH

Remove duplicate character from string without using inbuilt function.

Hello,
Below program is for remove duplicate characters from given string. you can see that I have given string name as "hemanshu goswami". in that string duplicate characters are like 'h','m','a','s' and etc. so at the end you will be see output as "hemansu gowi". means that if any duplicate character will come, this program will allow it to display it again. hope you can enjoy and understand it.

class Program
    {
        static void Main(string[] args)
        {
            string s = "hemanshu goswami";
            string final = "";
            foreach (char c in s)
            {
                if(string.IsNullOrEmpty(final) || !final.Contains(c)) //check if final string contains any existing character or not.
                {
                    final += c;
                }
            }
            Console.Write(final);
            Console.ReadLine();
 }

output:hemanshu gowi

Remove extra space from string without using inbuilt function.

Below program is for remove extra space from given string.it will remove extra space from given words and give you formatted output.
Hope you will enjoy it.

class Program
    {
        static void Main(string[] args)
        {
            string s = "My name  is    john";
            string final = "";
            int spacecount = 0;
            foreach (char c in s)
            {
                string isEmpty = c.ToString();
                if (isEmpty == " ")
                {
                    spacecount++;
                    continue;
                }
                if (spacecount >= 1)
                {
                    spacecount = 0;
                    final += " ";
                }
                final += c;
             

            }
            Console.Write(final);
            Console.ReadLine();
        }

    }

Output:My Name is john

Jagged Array

What is Jagged Array? Jagged array is called as "array of arrays". when you need a data inside your array element at that time you...