What's new

C# Pls help po 3x4 array. anu po ang mali ko hindi po ako makapag lagay ng user input?

ja_mario14

Addict
Joined
Apr 1, 2022
Posts
102
Reaction
16
Points
89
Pahelp po. hndi ko na po alam kung saan ang mali ko. hindi po ako makapag input ng value.

eto po yung code.
=========================================================

using System;

class LabExercise12
{
static void Main() {

int row, col;
int[,] array = new int[3,4];


for(row=0;row<3;row++)
{
for(col=0;col<4;col++)
{
Console.Write("Element [{0},{1}] : \n",row,col);
array[row,col] = Convert.ToInt32(Console.ReadLine());
}
}

Console.Write("\nThe content of 3x4 array:");
for(row=0;row<3;row++)
{
Console.Write("\n");
for(col=0;col<4;col++)
Console.Write("{0}\t",array[row,col]);
}
Console.WriteLine("\n\n");
}
}


==========================================================

Ganitong output po sana yung naka-attach na image.


PS: sorry po, nilagay ko yung code as text. wala po kasi akong button nung attach code.


Thank you in advance po.

View attachment 1901670 View attachment 1901672
 
Last edited:
C#:
 class LabExercise12
    {
        static void Main()
        {

            int row, col;
            int[,] array = new int[3, 4];


            for (row = 0; row < 3; row++)
            {
                for (col = 0; col < 4; col++)
                {
                    Console.Write(String.Format("Element [{0},{1}] : ", row, col));
                    array[row, col] = Convert.ToInt32(Console.ReadLine());
                }
            }

            Console.Write("\nThe content of 3x4 array:");
            for (row = 0; row < 3; row++)
            {
                Console.Write("\n");
                for (col = 0; col < 4; col++)
                    Console.Write(String.Format("{0}\t", array[row, col]));
            }
            Console.WriteLine("\n\n");
            Console.ReadKey();
        }
    }
 

Similar threads

Back
Top