0

I can't figure out where the problem is in my program?

#include <stdio.h>
int main()
{
  int a[2][2]={{1,2},{3,4}};
  printf("The value of a[2][1] is %d",a[2][1]);
  return(0);
}

I expected the answer to be 3, it's actually wow! 32765 wait! what!? I'm pretty confused. Can someone help?

1 Answers1

1

You don't have anything in the spot a[2][1]. I think what you meant to put is a[1][0]. Remember that the index starts at 0 not at 1.

The reason why you are getting that big number is because that number was already sitting there in that memory location. It has nothing to do with the array you created.

Mr.Young
  • 324
  • 5
  • 14