Jon Smit

Jon Smit

  • 1.9k
  • 6
  • 672

passing parameters with out

Dec 17 2018 7:15 AM

write the method GetModeAverage, which takes an array of integers as a parameter, and another integer as out parameter.
Assign the Mode average to the out integer parameter. The Mode average is the number that appears most frequently.
 
using System;

namespace HelloWorld
{
class Program
{
private static void GetModeAverage(int[] numbers, out int mode)
{
Array.OrderByDescending(numbers);
mode = numbers[0];
}

static void Main(string[] args)
{
int mode;

int[] numbers = { 1, 2, 3, 3, 4, 5, 5, 5, 6, 7, 8, 8 };

GetModeAverage(numbers, out mode);

Console.WriteLine(mode);
}
}

Answers (3)