# Statistics V2 C# Exercise - C# Programming Course

### Example Code

``````using System;
public class exercise78
{
public static void Main()
{
float[] numbers = new float[1000];
int count = 0;

float max = 0.0f, min = 0.0f, total = 0.0f, searchNumber = 0.0f;
bool found;

int option = 0;
do
{
Console.WriteLine("2. Show");
Console.WriteLine("3. Search");
Console.WriteLine("4. Statistics");
Console.WriteLine("5. Exit");

if (option != 5)
{
switch (option)
{

Console.WriteLine("Enter a number: ");

max = numbers[count];
min = numbers[count];

total += numbers[count];

count++;

if (max < numbers[count])
max = numbers[count];

if (min > numbers[count])
min = numbers[count];

break;
case 2: // Show

for (int i = 0; i < count; i++)
Console.WriteLine("{0} ", numbers[i]);

break;
case 3: // Search

Console.WriteLine("Enter a number for search: ");

for (int i = 0; i < count; i++)
if (numbers[i] == searchNumber)
found = true;

if (found)
Console.WriteLine("Number {0} found a amount of {1} "
, numbers[i]);
else
{
found = false;
}

break;
case 4: // Statistics

Console.WriteLine("Total data: {0}", count + 1);
Console.WriteLine("Sum: {0}", total);
Console.WriteLine("Average: {0}", total / (count + 1));
Console.WriteLine("Min number: {0}", min);
Console.WriteLine("Max number: {0}", max);

break;
default:

Console.WriteLine("Error, option 1-5");
break;
}
}
}
while (option != 5);
}
}``````