using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ArrayManipulation
{
class Program
{
static void Main(string[] args)
{
int[] myarr = new Int32[] { 1, 8, 9, 88, 77, 76, 22, 225 };
int mxval = 0;
int secondHv = 0;
int sum = 0;
int count = 0;
int avg = 0;
foreach (int i in myarr)
{
if (i > mxval)
{
secondHv = mxval;
mxval = i;
}
else if (i >
secondHv)
secondHv = i;
sum += i;
count++;
avg = sum / count;
}
Console.WriteLine(mxval);
Console.WriteLine(secondHv);
Console.WriteLine(sum);
Console.WriteLine(count);
Console.WriteLine(avg);
Console.ReadLine();
}
}
}
No comments:
Post a Comment