**I use Microsoft Visual Studio .NET 2003's compiler

I having trouble trying to create a 10x10 2D array. The user is supposed to give me a starting number and then it fills the array from top to bottom with ascending numbers. I am terrible at arrays and this task doesn't help me at all! If anyone would help I would gladly appreciate it!

Recommended Answers

All 10 Replies

I think the problem is on line 42.

The dynamic declination flag was accidentally switched to EIEIO. Check your atomic memory pool for floaters because they're probably causing the kernel to pop. But be careful because the memory manager is volatile and could cause the entire pipeline to dump core.

Unquestionably line 42, the whole 10x10 2D array is dumped onto the atomic memory pool heap! Not even one bit left!

Thanks for the help guys!.....?

Now, is there anyone who can help me without being a fool?

It's possible that they're poking at you because you didn't post any code. Please read the Announcement.

Even if this isn't a homework assignment, you're not going to get much help around here if you don't provide any code to troubleshoot.

>Now, is there anyone who can help me without being a fool?
Foolishness begets foolishness. Post some code and we'll help you with it. That's far more effective than asking a vague question and leaving the answer open to interpretation.

void twod()
{   
    int startingnum;
    int my2darray[10][10];

    cout << "\nPlease type in a starting number: ";
    cin >> startingnum;
    cout << endl << endl;

    for (int i=startingnum+100 ; startingnum < i ; startingnum++)

    cout << startingnum;
    cout << endl << endl;
}// End of twod

Sorry, I just need to know how to put startingnum in a 10x10 2D array named my2darray.

#include <iostream>
using namespace std;

void twod()
{
   int startingnum;
   int my2darray[10][10];

   cout << "Please type in a starting number: ";
   cin  >> startingnum;
   cout << endl << endl;

   for ( int i = 0, k = startingnum + 100; i < 10 ; ++i )
   {
      for ( int j = 0 ; j < 10 ; ++j )
      {
         my2darray[i][j] = k++;
         cout << "my2darray[" << i << "][" << j << "] = "
              << my2darray[i][j] << endl;
      }
   }
   cout << endl;
}// End of twod

int main()
{
   twod();
   return 0;
}

thanks for the help dave, but that wasn't what I needed. Maybe this pic of an example of a 2D array will help.

>but that wasn't what I needed
Maybe I'm just bitter, but don't you think it's trivial to take what Dave showed you and derive this to get what you want?

int k = 1;
for (int i = 0; i < 10; i++) {
  for (int j = 0; j < 10; j++)
    array[i][j] = k++;
}

Then you can even use the same trick to print:

#include <iomanip> // For setw

for (int i = 0; i < 10; i++) {
  for (int j = 0; j < 10; j++)
    cout<< setw(5) << aray[i][j];
  cout<<endl;
}

Or are you completely helpless? If you are then I suggest you quit right now. Helpless people don't last long as programmers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.