Answer to Question #309758 in C# for chi

Question #309758

Machine Problem 5.7. 

Write a program using two-­‐dimensional arrays that determines the highest and lowest of the 12 input

values. 


Sample input/output dialogue:


Enter twelve numbers: 13 15 20 13 35 40 16 18 20 18 20 19 

The highest is: 40 

The lowest is: 13


1
Expert's answer
2022-03-13T01:11:17-0500
using System;

namespace twodim_maxmin
{
    class Program
    {
        public static void Main(string[] args)
        {
            int i,j, max, min;
            int [ , ] array = new int[4,3];
            Console.WriteLine("Enter twelve numbers:");
            for (i=0; i<4; i++)
                for (j=0; j<3; j++)
                    array[i,j] = Convert.ToInt32(Console.ReadLine());
            max = array[0,0];
            min = array[0,0];
            Console.WriteLine();
            Console.WriteLine("Array: ");
            for (i=0; i<4; i++)
            {
                for (j=0; j<3; j++)
                {
                    Console.Write("{0} ", array[i,j]);
                    if (max < array[i,j])
                        max = array[i,j];
                    if (min > array[i,j])
                        min = array[i,j];
                }
                Console.WriteLine();
            }
            Console.WriteLine();
            Console.WriteLine("The highest is: {0}", max);
            Console.WriteLine("The lowest is: {0}", min);
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

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
New on Blog
APPROVED BY CLIENTS