hello,
i have this assignment but i got stuck on number 2.
Question 1: Create a 3x3 array, each filled with a digit 1-9 so that the array resembles a num pad. Use for loops and construct 3 different, correct ways to print the elements of this array.

Question 2: Calculate and then print the product of the elements of the first 2 rows of this array.
It has 3 more parts and I know how to do others but don't know how to do number 2.
thank you

Recommended Answers

All 2 Replies

Can you ask a more specific question? What is it you don't understand?

To put it in other words, I believe what you are being asked is to take all the values from the first two rows and multiply them.

If you think of your 3x3 array as an array of arrays:

//demonstrative
int A[3][3] == [ [a,b,c], [d,e,f], [h,i,j] ];

You know the size of your arrays, so you can loop through them A[0][0] through A[0][2] and A[1][0] through A[1][2].

You can do this using two for loops (one for each dimension, that iterates through the sizeof each row), or using a single for loop for each dimension (since you know you only want row 0 and 1.

Alternatively, you can access them by pointer (since that's basically what they are under the hood any how).

Lots of ways to skin the cat..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.