-2

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

Votes + Comments
Read more and write some codes.
4
Contributors
3
Replies
7
Views
13 Years
Discussion Span
Last Post by gruffy321
1

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:

Rows/Columns	Column 0	Column 1	Column 2	Column 3
Row 0		myValue[0][0]	myValue[0][1]	myValue[0][2]	myValue[0][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:

Rows/Columns	Column 0	Column 1	Column 2
Row 0		5		-3		0
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

-1

nice , but dont forget to close array initialisations with a

;

ching ching

Edited by gruffy321: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.