programming example about how to store value in array:

Prabhukiran345
Posted by Prabhukiran345 under C# category on | Points: 40 | Views : 547
using System;

namespace store_value_in_array
{
class Program
{
static void Main(string[] args)
{
int i;
int[] arr = new int[5]; // 5 size array

// Accepting value from user
for (i = 0; i < 5; i++)
{
Console.Write("\nEnter your number:\t");
//Storing value in an array
arr[i] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("\n\n");
//Printing the value on console
for (i = 0; i < 5; i++)
{
Console.WriteLine("you entered {0}", arr[i]);
}
Console.ReadLine();
}
}
}


OUTPUT:

Enter your number: 7
Enter your number: 3
Enter your number: 5
Enter your number: 6
Enter your number: 8


you entered 7
you entered 3
you entered 5
you entered 6
you entered 8

Comments or Responses

Login to post response