Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Collections Arrays Jagged Arrays

help me plz

Challenge Task 1 of 1

Return a multiplication table consisting of an array of arrays. The table should contain all of the products of integers from 0 to maxFactor. For example, if maxFactor is 3 the resulting multiplication table should contain the following: 0 0 0 0 0 1 2 3 0 2 4 6 0 3 6 9

Bummer! Your code could not be compiled. Please click on "Preview" to view the compiler errors. Restart Preview Get Help Recheck work Math.cs

array 1 namespace Treehouse.CodeChallenges 2 { 3 public static class MathHelpers 4 { 5 public static int[,] BuildMultiplicationTable(int maxFactor) 6 { 7 for (int i = 0; i < array.Length; i++) 8 { 9 System.Console.Write("maxFactor({0}): ", i); 10 } 11 ā€‹ 12 ā€‹ 13 } 14 } 15 } 16 ā€‹

Math.cs
namespace Treehouse.CodeChallenges
{
    public static class MathHelpers
    {
        public static int[,] BuildMultiplicationTable(int maxFactor)
        {
            for (int i = 0; i <  array.Length; i++)
        {
            System.Console.Write("maxFactor({0}): ", i);
        }


        }
    }
}

2 Answers

Steven Parker
Steven Parker
231,248 Points

It looks like you asked this twice.

Here are the hints I gave on the original question:

  • you don't need to write to the console, just build and return the table.
  • you might need a second loop nested inside the first to handle both dimensions.
  • it's a multiplication table ā€” don't forget to multiply.
Name:GoogleSearch orJonathan Sum
Name:GoogleSearch orJonathan Sum
5,039 Points

@Steven Parker OK, Can you watch this video first"https://teamtreehouse.com/library/jagged-arrays"? After watching it, can you tell me that we can do complete this code challenge? The whole video are done in the console. i still don't know how to do this in the work space.

S.Amir Nahravan
S.Amir Nahravan
4,008 Points

shawn khah Here is complete example of this question

namespace Treehouse.CodeChallenges { public static class MathHelpers { public static int[][] BuildMultiplicationTable(int maxFactor) { maxFactor++; int[][] result= new int[maxFactor][]; for(int i = 0; i<maxFactor; i++) { result[i] = new int[maxFactor]; for(int j=0; j<maxFactor; j++) { result[i][j] = i*j; } } return result; } } }