C# program to input and output 5 numbers using array and function

Category > CSHARP || Published on : Sunday, November 1, 2020 || Views: 35 || input and output 5 numbers using array and function


Here Pawan Kumar will explain how to write C# program to input and output 5 numbers using array and function

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication
{
    class Array
    {
        static void Main(string[] args)
        {
            int[] a = new int[5];

            GetArray(a);
            Console.WriteLine("ENTERED NUMBER IS\n");
            for (int i = 0; i < a.Length; i++)
                Console.WriteLine("a[" + i + "]=" +  a[i]);
            Console.ReadLine();
        }
        static void GetArray(int[] a)
        {

            Console.WriteLine("ENTER 5 NUMBERS");
            for (int i = 0; i < a.Length; i++)
	a[i] =  int.Parse(Console.ReadLine());
        }

    }
}