single dimensional array in C#

 

For Example: Write a program to demonstrate the use of single dimensional array.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace ConsoleApplication5

{

class Program

    {

static void Main(string[] args)

        {

int[] arr = new int[5];

int i,max;

Console.Write("Enter Five values:");

for (i = 0; i < 5; i++)

          arr [i] = Convert.ToInt32(Console.ReadLine());

             max  = arr [0];

for (i = 1; i < 5; i++)

               {

if (arr[i] > max)

                       max = arr[i];

               }

Console.WriteLine(" Maximum Number is: {0} ", max);

Console.ReadLine();             

 

        }

    }

}

Output:

Comments

Popular posts from this blog

simple program C#

Regular Expression Validator Control in asp.net

two dimension array in C#