We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Thursday, June 18, 2015

Write a program to check pandigital number or not


    class Program
    {
        static void Main(string[] args)
        {
            int num, rem, lenth = 0, temp = 0, n, max, input;
            Console.WriteLine("Enter the input number");
            num = n = input = int.Parse(Console.ReadLine());
            while (num > 0)
            {
                num = num / 10;
                lenth++;
            }
            int[] arr = new int[lenth];
            max = arr[0];
            while (n > 0)
            {
                rem = n % 10;
                n = n / 10;
                if (rem == 0)
                {
                    Console.WriteLine("The given number is not pan digit number");
                    return;
                }
                else
                {
                    for (int k = 0; k < arr.Length; k++)
                    {
                        if (arr[k] != 0)
                        {
                            if (rem == arr[k])
                            {
                                Console.Write("Given number is not pandigit number");
                                return;
                            }
                        }
                        else
                        {
                            arr[temp] = rem;
                            temp++;
                            if (arr[k] > max)
                            {
                                max = arr[k];
                                break;
                            }

                        }
                    }
                }

                if (lenth == max)
                {
                    Console.WriteLine("The given number is pandigital number");
                }
                else
                {
                    Console.WriteLine("The given pandigit number is not pandigi number");
                }
                Console.ReadLine();
            }
           
        }


    }
OUTPUT:

No comments: