Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7783389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:49:30+00:00 2026-06-01T19:49:30+00:00

Can somebody please tell me what is wrong here? int arr[15][1]; int main() {

  • 0

Can somebody please tell me what is wrong here?

int arr[15][1];
int main()
{
  int x;
  for(x=0; x<15; x++)
  {
    arr[x][0] = x;   
    arr[x][1] = x;    
  }  
  int y;
  for(y=0; y<15; y++)
  {
    printf("[%d][0]=%u\t", y, arr[y][0]);
    printf("[%d][1]=%u\n", y, arr[y][1]);
  }
}

it gives me the below output, I can’t figure out what’s wrong, while the output for [0][0] and [0][1] should be 0, 0 and so on for the rest?

[0][0]=0                [0][1]=1
[1][0]=1                [1][1]=2
[2][0]=2                [2][1]=3
[3][0]=3                [3][1]=4
[4][0]=4                [4][1]=5
[5][0]=5                [5][1]=6
[6][0]=6                [6][1]=7
[7][0]=7                [7][1]=8
[8][0]=8                [8][1]=9
[9][0]=9                [9][1]=10
[10][0]=10              [10][1]=11
[11][0]=11              [11][1]=12
[12][0]=12              [12][1]=13
[13][0]=13              [13][1]=14
[14][0]=14              [14][1]=14
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:49:32+00:00Added an answer on June 1, 2026 at 7:49 pm

    Here

    int  arr[15][1];
    

    you declare an array of 15×1 elements (so indices 0-14 for the first dimension and 0-0 for the second dimension), then you set the 0 and 1 elements of the second dimensions. As there is no element 1 of the second dimension, arr[x][1] = x; is the same as arr[x+1][0] = x;

    Basically, an array is a contiguous memory to store elements. A multi-dimentional array can be though of as an array of arrays: the second dimension is repreated the size of the first dimention times. So when you overindex the second dimension, you are accessing the next element of the first dimension

    This also means that arr[x][1] = x accesses memory that was not allocated for the array when x==14

    You most likely meant to have two elements in the second dimension, so declare the array as:

    int arr[15][2];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can not figure out how to use CATransform3DMakeRotation() . Can somebody please tell
Can somebody please explain what is wrong in the below applescript: tell the application
Can somebody please tell me what is wrong with the following pom.xml? i'm getting
Can somebody please tell me what is wrong with the following applescript set sourceFile
Can somebody please tell me what || this doing here (function() { window.myapp =
can somebody please tell me where i m wrong why this RMI chat application
Can somebody please tell me how I can get google analytics on every page
Can somebody please tell, what's the difference between the following two statements: TimeZone.getTimeZone(America/New_York) and
Can somebody please tell me what I am missing in this formula in SSRS?
Can somebody please explain how to find out if full text search is enabled

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.