Answer to Question #188972 in C# for CHANDRASENA REDDY

Question #188972

Write a program to define a two dimensional array of numbers to store 5 rows and 6 columns. Write a code to accept the data, assign it in array, and print the data entered by the user.


1
Expert's answer
2021-05-08T22:32:37-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace C_SHARP
{
    class Program
    {


        static void Main(string[] args)
        {
            
            //a two dimensional array of numbers to store 5 rows and 6 columns.
            int[,] numbers = new int[5, 6];
            //Write a code to accept the data, assign it in array
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0;j < 6; j++)
                {
                    Console.Write("Enter value [{0}][{1}]: ",i,j);
                    int.TryParse(Console.ReadLine(), out numbers[i,j]);
                }
            }
            //print the data entered by the user.
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    Console.Write("{0,5} ", numbers[i, j]);
                }
                Console.WriteLine();
            }
            
            Console.ReadLine();
        }
    }
}





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