TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
pad pad
NA
20
17.4k
can anyone help for program calls a method
Oct 9 2014 2:34 AM
// Program calls a method that finds and returns
// the median value in an array
// The median value is the middle value from largest to smallest
// If there are an even number of values, the
//median is the mean of the two middle values
using System;
class DebugSeven4
{
void Main()
{
int[] firstArray = {10, 9, 2, 3, 5, 6};
int[] secondArray = (112, 456, 782);
int[] thirdArray = {9, 12, 45, 82, 84, 67, 2, 6};
Console.WriteLine("The median value of the first array is {0}",
FindMedian(firstArray));
Console.WriteLine("The median value of the second array is {0}",
FindMedian(secondArrray));
Console.WriteLine("The median value of the third array is {0}",
FindMediam(thirdArray));
}
private static double FindMedian(int[] array)
{
double median;
middle = array.Length / 2;
Array.Sort(array);
if(array.Length % 2 == 0)
median = (double)(array[middle - 1] + array[middle]) / 2;
else
median = array[mid];
return median;
}
}
Reply
Answers (
2
)
Not able to execute this program
Url friendly with parameters help.