Two dimensional array Learn programming C#



Lesson:

Arrays, Structures and Strings


Exercise:

Two dimensional array


Objetive:

Write a C# program to ask the user for marks for 20 pupils (2 groups of 10, using a two-dimensional array), and display the average for each group.


Code:

using System;
public class exercise77
{
    public static void Main()
    {
        float[,] puntuations = new float[10, 10];
        for (int i = 0; i < 2; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                Console.WriteLine("Enter the puntuation {0} group {1}: ", j + 1, i + 1);
                puntuations[i, j] = Convert.ToSingle(Console.ReadLine());
            }
        }
    }
}



Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.