1. ## 3-D arrays

overall goal is to understand the use multi dimensional array

For example, suppose

5 stdudents is stuying in fisrt standard Whose marks are as follows 40, 65, 98, 47, 65.

8 stdudents is stuying in second standard Whose marks are as follows 58, 23, 40, 80, 65, 98, 47, 65.

10 stdudents is stuying in second standard Whose marks are as follows 47, 65, 58, 23, 40, 80, 65, 98, 47, 65.

I want to store all student marks

Can i use 3d array to store all student marks ?

Is my program storing all student marks ?

Code:
```#include<stdio.h>

int main ()
{
int student[5][8][10] = {{40, 58, 47}, { 65, 23, 65}, {98, 40, 58}, {47,80, 23}, {65, 65, 40}, {0, 98, 80}, {0, 47, 65}, {0, 65, 98}, {0, 0, 47} {0, 0, 65} };

return 0;

}```

2. I really don't think the array will really do what you want in the case given. And your sample array doesn't really match the data given.

For example how do you know that the 5 students in the first use case are the same students in the second use case that has 8 students.

3. Originally Posted by jimblumberg
I really don't think the array will really do what you want in the case given. And your sample array doesn't really match the data given.

For example how do you know that the 5 students in the first use case are the same students in the second use case that has 8 students.
I tried to make an example As much as i can understand If I have an integer values like the marks of 5 students for first stranded, marks of 8 students for second stranded, marks of 10 students for student stranded,

I can declare three arrays

Code:
```#include<stdio.h>
int main ()
{
int fisrt[5] = {40, 65, 98, 47, 65};
int second[8] =  { 58, 23, 40, 80, 65, 98, 47, 65};
int third[10] = {47, 65, 58, 23, 40, 80, 65, 98, 47, 65};

return 0;
}```
My question was that apart from using the three arrays, can I not use the 3D array?

Originally Posted by jimblumberg
And your sample array doesn't really match the data given.
.
I did not understand where they doesn't matches

4. > 5 stdudents is stuying in fisrt standard Whose marks are as follows 40, 65, 98, 47, 65.
> 8 stdudents is stuying in second standard Whose marks are as follows 58, 23, 40, 80, 65, 98, 47, 65.
> 10 stdudents is stuying in second standard Whose marks are as follows 47, 65, 58, 23, 40, 80, 65, 98, 47, 65.
You have 23 students in total.

> int student[5][8][10]
Now you have 480 student marks ( 5 * 8 * 10 )

But then again, it's hard to see through all the typos to what you're getting at.
Is the second "second" really meant to be third perhaps?

Code:
```#define MAX_STANDARD 3
#define MAX_STUDENTS 10
int studentmarks[MAX_STANDARD][MAX_STUDENTS] = {
{ 40, 65, 98, 47, 65 },  // the remaining 5 slots will be 0
{ 58, 23, 40, 80, 65, 98, 47, 65 }, // the remaining 2 slots will be 0
{ 47, 65, 58, 23, 40, 80, 65, 98, 47, 65 },
};```

5. Originally Posted by Salem
>

But then again, it's hard to see through all the typos to what you're getting at.
look at new example, program to store temperature of three cities of a week

given data

City 1, Day 1 = 33
City 1, Day 2 = 34
City 1, Day 3 = 35
City 1, Day 4 = 33
City 1, Day 5 = 32
City 1, Day 6 = 31
City 1, Day 7 = 30

City 2, Day 1 = 23
City 2, Day 2 = 22
City 2, Day 3 = 21
City 2, Day 4 = 24
City 2, Day 5 = 22
City 2, Day 6 = 25
City 2, Day 7 = 26

City 3, Day 1 = 24
City 3, Day 2 = 22
City 3, Day 3 = 21
City 3, Day 4 = 22
City 3, Day 5 = 22
City 3, Day 6 = 23
City 3, Day 7 = 26

Code:
```#define  max_cities 3
#define  temperature 7

int main
{
int temp[3][10] = { {33,34, 35 33, 32, 31, 30}, {32, 22, 21, 24, 22, 25, 26}, { 24, 22, 21, 22, 22, 23, 26} }
return 0;
}```
The first range says the array has three elements The second range says that each of these three arrays is an array of seven elements.

6. Right, so you've got 2D arrays figured out.

A 3D array would be something like
Code:
`int marks[YEARS][COURSES][STUDENTS];`