Answer to Question #294397 in C# for playhard

Question #294397

In C#, please.

Create a program that will accept 25 inputs into integer array Task2DArray and

compute for the sum and difference of all the elements.


1
Expert's answer
2022-02-07T00:55:06-0500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
           // Create a program that will accept 25 inputs into integer array Task2DArray and compute for the sum and difference of all the elements.
            int[,] arr= new int[6,6];
            int diff = 0;
            int sum = 0;

            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    Console.WriteLine("Input [{0}, {1}] number :", i + 1, j + 1);
                    arr[i, j] = Convert.ToInt32(Console.ReadLine());
                }
            }

            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    sum = sum + arr[i, j];
                    diff = diff - arr[i, j];
                }
            }

            Console.WriteLine("Sum: {0}", sum);
            Console.WriteLine("Diff: {0}", diff);

            Console.ReadKey();
        }
    }
}

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