Sponsored Ad

Saturday, March 12, 2011

C# Program to Find Smallest Number of a Numeric Array

The below program will help you to find minimum number of a numeric array. This is efficient program and will work for negative and positive numbers both.

Please comment in case of any questions.

C# Program to Find Smallest Number of a Numeric Array

using System;

namespace MyApp
{
    class min_class
    {
        static void Main(string[] args)
        {
            int[] number_array = {-1,-5,10};
            int minimum_number = number_array[0];

            foreach (int int_num in number_array)
            {
                if (int_num < minimum_number)
                {
                    minimum_number = int_num;
                }               
            }
            Console.WriteLine("minimum number in array: {0}", minimum_number);
            Console.ReadLine();
        }       
    }
}

No comments:

Post a Comment

Sponsored Ad

Development Updates