Answer to Question #42768 in C# for priya

Question #42768
Sam is working on an application wherein he needs to accept the size of a one dimensional array
and its values. He needs to identify the largest and smallest number in the array and based on that
he needs to display the result. Help him to create the application
1
Expert's answer
2014-05-28T09:52:44-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _42768
{
class Program
{
static void Main(string[] args)
{
int size;//array size
Console.Write("Array size: ");
size = Convert.ToInt32(Console.ReadLine());
double[] arr = new double[size];//array
//reading array from keyboard
for(int i = 0; i < size; i++)
{
Console.Write("Array element #" + (i+1) + ": ");
arr[i] = Convert.ToDouble(Console.ReadLine());
}
//max and min
Console.WriteLine("Max = " + arr.Max());
Console.WriteLine("Min = " + arr.Min());
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS