0

How can I declare 20 times

int p[] = { 1,2,3,4,5};
int p[] = { 6,7,8,9,10};
.
.
.

Let's say i have a matrix 20x20. each row is a pointer above

1

1 Answer 1

1

You can do this using a 20X20 2-dimensional array.

int p[][]={{1,2,3,4,5},
           {6,7,8,9,10},
           {11,12,13,14,15},
           .....
           .....
          }

EDIT: you can refer to the fifth row using this:

for(int i=0; i<5; i++)
{
   printf(" %d",p[4][i]);
}
Sign up to request clarification or add additional context in comments.

3 Comments

But how will i refer to ( lets say row number 5 ) later?
you can refer to row number 5 using p[4].
syntax error.. it refers to the second [] in p[][] declaration

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.