Programming Course in C# ¡Free!

Two-dimensional array

 Saturday, April 06, 2013 published by Exercises C#
Proposed exercise

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.

Output



Solution


using System;
public class TwoDimensional
{
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() );
}
}
}
}