Using Multidimensional aarays
What codes are suitable to display an output wherein 2 inputs are required:
For example, the program ask for 2 inputs:
1st input: 2
2nd input: 5
The program will display an output like this:
1 2 3 4 5
2 4 6 8 10
Another example: 5 and 3
Output will be:
1 2 3
2 4 6
3 6 9
4 8 12
5 10 15
Sorry if i ask these questions. I'm still a newbie here. I know I'll use some looping methods with this kind of program but I'm still confused with the algorithm.
Thanks for helping me out.
Mervha NifflemhellPosted Jun 23, 2008, 12:41 AM
Scott LyslePosted Jun 22, 2008, 8:08 AM
You would not need to use a multidimensional array: This will do it:
static void Main(string[] args)
{
int ol;
int il;
Console.Write("Input First Value: ");
ol = Convert.ToInt32(Console.ReadLine());
Console.Write("Input Second Value: ");
il = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i < ol+1; i++)
{
for (int j = 1; j < il+1; j++)
{
Console.Write(i*j + " ");
}
Console.WriteLine();
}
Console.WriteLine("End");
Console.Read();
}