using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Array_Ex_2
{
class Program
{
static void Main(string[] args)
{
int[] x = new int[20]; //Create and define the size of x array
Random rand = new Random();
//initialize array x with random number between -20, 20
for (int i = 0; i < x.Length; i++)
{
int n = rand.Next(-20, 21);
x[i] = n;
//Display array x
Console.WriteLine("Index: {0} Value: {1}", i, x[i]);
}
//Display propery length of array x
Console.WriteLine("\nArray x propery: {0}", x.Length);
Console.ReadLine();
}
}
}
No comments:
Post a Comment