0% found this document useful (0 votes)
33 views2 pages

CS 223 Multi-D Array in Class Exercise

1) Declare a 16-integer array and assign values to the first three elements. Assign the sum of the first three elements to the fourth element. 2) Declare a 2D 2x8 integer array and initialize all elements to 0. Set the element at row 0, column 7 to 100. 3) Declare a 3D 9x9x9 integer array and initialize all elements to 0. Set the center element of the 3D array to 1.

Uploaded by

Zack Overfield
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

CS 223 Multi-D Array in Class Exercise

1) Declare a 16-integer array and assign values to the first three elements. Assign the sum of the first three elements to the fourth element. 2) Declare a 2D 2x8 integer array and initialize all elements to 0. Set the element at row 0, column 7 to 100. 3) Declare a 3D 9x9x9 integer array and initialize all elements to 0. Set the center element of the 3D array to 1.

Uploaded by

Zack Overfield
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

CS 223 In Class Exercise – arrays and multi-

dimensional arrays
Single dimensional array
1. Declare a 16-integer array ilist and assign 1, 2, and 3 to the first three elements.

2. Given ilist declared in question 1, write a statement to assign the forth element (at index 3) with
the sum of first three elements in ilist, (index at 0, 1, 2)

3. Declare a 32-char array name and assign string “Hello” as its initialization value.

4. Given name declared in question 3, write a statement to print out the string content in name.

printf(“ “, );

2D array
5. Declare an 2D 2×8 integer array iMatrix and initialize all elements with 0.

6. Use iMatrix declared in question 5, write a statement to set the element at row 0 and column
7 in iMatrix to 100.

7. Declare 2D 4×8 char array strlist and use following strings to initialize rows: “abc”, “def”,
“ghi”, and “jkl”.
8. Given strlist declared in question 7, write a statement to print out the content in row 2 (the 3rd
row) of strlist.

printf(“%s”, );
--------------------------------------------

3D array
9. Declare 3D 9×9×9 integer array cube and initialize all elements with 0.

10. Given cube declared in question 9, write a statement to set the center of 3D cube to 1.

You might also like