944,216 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 105890
  • C RSS
Sep 27th, 2004
-2

2d Array

Expand Post »
hi can someone help how to make a program or exampel of program using two dimensional array. Or can someone help me to make program by this problem >Write a program using two dimensional array that searches a number and display the of times it occurs on the list of twelve input value.
I'm asking for help coz my Prof. didn't explain it very well
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
iorisendoh is offline Offline
2 posts
since Sep 2004
Sep 27th, 2004
1

Re: 2d Array

Greetings,

Using a 2-Dimensional array isn't very difficult at all. In fact for simplicity, lets take a look how a 2-Dimensional array looks in all aspects.

int myValue[2][3];

We know this array is going to be a 2x3 rectangle. So lets see how this looks:

  1. Rows/Columns Column 0 Column 1 Column 2 Column 3
  2. Row 0 myValue[0][0] myValue[0][1] myValue[0][2] myValue[0][3]
  3. Row 1 myValue[1][0] myValue[1][1] myValue[1][2] myValue[1][3]

Not bad at all. How about if we initialize this array:

int myValue[2][3] = { {5, -3, 0}, {10, 17, -25} };

There are two blocks, with 3 numbers inside each initializing our 2x3 array completlely:

  1. Rows/Columns Column 0 Column 1 Column 2
  2. Row 0 5 -3 0
  3. Row 1 10 17 -25

This should all be making sense. To set your array's data outside of the initilization isn't hard at all:

int main() {
	int myValue[2][3]

	myValue[0][0] = 5;
	myValue[0][1] = -3;
	myValue[0][2] = 0;

	myValue[1][0] = 10;
	myValue[1][1] = 17;
	myValue[1][2] = -25;

	return 0;
}

So think of a 2-Dimensional array as a rectangle. Rows and Columns, right and down. Once you have this down, please feel free to ask more questions.


- Stack Overflow
Reputation Points: 26
Solved Threads: 4
Junior Poster
Stack Overflow is offline Offline
185 posts
since Sep 2004
Nov 5th, 2004
0

Re: 2d Array

sorry this my question
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hamsa is offline Offline
2 posts
since Nov 2004
Apr 29th, 2011
-1
Re: 2d Array
nice , but dont forget to close array initialisations with a
  1. ;
ching ching
Last edited by gruffy321; Apr 29th, 2011 at 10:11 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
gruffy321 is offline Offline
32 posts
since Mar 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: i have a problem comparing user input with the contents of a file
Next Thread in C Forum Timeline: how to access buffer of standart input





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC