using System; namespace Purush_Programs {

C# - PROGRAM SMALLEST NUMBER



using System;

namespace Purush_Programs
{

    public class Purush_SmallestNumber
    {
        public static void Main()
        {
            int[] arr = new int[100];
            int i, min, n;
            Console.Write("\n\nFind Smallest Number in an array :\n");
            Console.Write("--------------------------------------------------\n");

            Console.Write("Input the number of elements to be stored in the array :");
            n = Convert.ToInt32(Console.ReadLine());

            Console.Write("Input {0} elements in the array :\n", n);
            for (i = 0; i < n; i++)
            {
                Console.Write("element - {0} : ", i);
                arr[i] = Convert.ToInt32(Console.ReadLine());
            }

            // Your Logic Goes Here

            min = arr[0];


            for (i = 1; i < n; i++)
            {
                if (arr[i] < min)
                {
                    min = arr[i];
                }

            }
            Console.Write("Smallest Number is : {0}\n", min);
            Console.ReadKey();
        }
    }
}

0 comments: