Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,340 --> 00:00:09,120
OK, so in this video, we are going to talk about the declaration of two dimensional arrays, and the
2
00:00:09,120 --> 00:00:15,180
first thing we usually learn when working with different data types is how to declare them.
3
00:00:15,840 --> 00:00:24,690
And by saying how to declare them, I actually mean, how can we make our computer be aware that they
4
00:00:24,690 --> 00:00:26,430
really do exist?
5
00:00:26,440 --> 00:00:30,690
And that's actually very similar to working with boxes.
6
00:00:30,690 --> 00:00:38,490
We first need to know that these boxes do exist before we can use them and I don't know, pecc something
7
00:00:38,490 --> 00:00:39,270
inside of them.
8
00:00:39,270 --> 00:00:39,730
Right.
9
00:00:40,290 --> 00:00:44,600
So the same goes for our lovely computers.
10
00:00:44,880 --> 00:00:52,530
And the first step that we have to make is to declare exactly what we are going to work with.
11
00:00:52,770 --> 00:01:01,350
And once we do so, the computer will first of all know that it exists OK, and that what we we've created
12
00:01:01,350 --> 00:01:04,240
and what we want to use it actually exists.
13
00:01:04,350 --> 00:01:12,420
So then we can work with it however we like and do all the things that we want to do with the design,
14
00:01:12,660 --> 00:01:20,430
bring the value to the screen, getting reading the the inputs from the user and whatever comes to your
15
00:01:20,430 --> 00:01:21,010
mind.
16
00:01:21,450 --> 00:01:27,300
So I hope the reason for why we need declaration is clear to you, as it already should be clear to
17
00:01:27,300 --> 00:01:28,410
you by this point.
18
00:01:28,410 --> 00:01:29,320
That's for sure.
19
00:01:29,850 --> 00:01:37,650
And as a quick reminder, I want to talk about the standard variable in how we use the declaration for
20
00:01:37,660 --> 00:01:37,950
them.
21
00:01:38,310 --> 00:01:43,050
And basically we had some simple following our syntax.
22
00:01:43,080 --> 00:01:49,170
So, for example, we had int num and double B and char my char and whatsoever.
23
00:01:49,440 --> 00:01:56,610
So we had the the name of the variable, which in the first line is just num, we had a type which is
24
00:01:56,610 --> 00:01:57,330
integer.
25
00:01:57,660 --> 00:02:06,420
And basically what we have created behind the scenes is a simple box labeled as num with type int in
26
00:02:06,420 --> 00:02:14,190
other examples, whereas you probably can see here on the screen is just double B, OK, so we created
27
00:02:14,190 --> 00:02:21,000
a variable called B, OK, that's its name and its type is double in charge of my char and so on.
28
00:02:21,240 --> 00:02:21,660
Right.
29
00:02:21,930 --> 00:02:30,540
That, that's how we have been working with the declaration of standard variable so far in later on.
30
00:02:30,540 --> 00:02:38,700
What we've done is that we have been working and declared a one dimensional arrays and what we've used
31
00:02:38,700 --> 00:02:41,760
was something like this ain't grades.
32
00:02:41,760 --> 00:02:49,010
And in the square brackets we use just the number of elements that we wanted this array to have.
33
00:02:49,020 --> 00:02:59,680
So Ingres of size five simply created us an array of integers of five integers and its name was grades.
34
00:02:59,730 --> 00:03:05,370
Also, we've we can do the same for any type like double char and so on.
35
00:03:05,460 --> 00:03:14,520
And just what I want to show you guys before we move on is only how the declaration of one dimensional
36
00:03:14,520 --> 00:03:20,560
array looks like OK, behind the scenes if we try to understand all the logic behind it.
37
00:03:20,880 --> 00:03:25,180
So first of all, you specify the type of the one dimensional array.
38
00:03:25,290 --> 00:03:27,920
Think of it as just one row of elements.
39
00:03:28,680 --> 00:03:32,760
Then you specify its name and finally you specify its size.
40
00:03:33,510 --> 00:03:40,330
And basically what it gives you is just a sequence, a row of elements of an initialized element.
41
00:03:40,350 --> 00:03:42,000
We just declare them.
42
00:03:42,690 --> 00:03:44,640
And basically, that's all.
43
00:03:44,640 --> 00:03:53,550
What I wanted to r like to recap and now we are ready to like to move on and to talk about how we can
44
00:03:53,910 --> 00:03:56,790
declare our two dimensional arrays.
45
00:03:57,060 --> 00:04:06,600
So we recall that when we have been working with one dimensional arrays, it was like just working with
46
00:04:06,600 --> 00:04:09,930
a single row of elements of the same type.
47
00:04:09,930 --> 00:04:10,370
Right.
48
00:04:10,380 --> 00:04:13,550
Just like we've done it with the int grades.
49
00:04:13,570 --> 00:04:20,460
OK, so it's an array, a sequence of elements and each element is of an integer type.
50
00:04:20,460 --> 00:04:29,610
And also you do remember that we talked about that are two dimensional arrays are simply like greed's
51
00:04:29,610 --> 00:04:31,860
of rows and columns.
52
00:04:32,250 --> 00:04:40,530
So if we are going to work with the greed of rows and columns, we've got to like to specify the size
53
00:04:40,530 --> 00:04:45,190
of the number of rows and the number of columns.
54
00:04:45,220 --> 00:04:49,670
OK, so in one dimensional arrays, we just specified one thing.
55
00:04:49,680 --> 00:04:52,490
OK, so what is the length of these rows?
56
00:04:52,490 --> 00:04:59,700
So basically how many columns does one dimensional array has and here what we are going to spend.
57
00:04:59,950 --> 00:05:11,890
Fi is simply both how many rows are we have and how many columns we have and for that, whenever we
58
00:05:11,890 --> 00:05:18,490
declare a two dimensional array, we will simply specify the size rows and columns, just like I said,
59
00:05:18,730 --> 00:05:20,910
and it will look like this.
60
00:05:20,920 --> 00:05:24,940
So first of all, you specify the type of the two dimensional array.
61
00:05:24,970 --> 00:05:30,640
OK, just like you've done it with one dimensional arrays, then you specify its name.
62
00:05:30,880 --> 00:05:32,320
OK, so there you go.
63
00:05:32,500 --> 00:05:33,710
Here you have its name.
64
00:05:34,270 --> 00:05:41,020
Then afterward, you specify the number of rows that we are going to use and the number of columns that
65
00:05:41,020 --> 00:05:42,220
we are going to use.
66
00:05:42,580 --> 00:05:45,990
So in the first bracket, we are going to specify the number of rows.
67
00:05:46,030 --> 00:05:50,710
OK, and it may be, for example, three rows and four columns.
68
00:05:50,740 --> 00:05:55,420
OK, so this will create a simple two dimensional grid.
69
00:05:55,450 --> 00:06:00,850
OK, with three rows, as you can see here on the screen and four columns.
70
00:06:00,850 --> 00:06:02,140
Pretty awesome, right?
71
00:06:02,160 --> 00:06:05,210
I mean, there's nothing complicated here, right.
72
00:06:05,230 --> 00:06:12,990
So basically we just are create the number of rows, specify the number of rows, the number of columns,
73
00:06:13,000 --> 00:06:13,750
and there you go.
74
00:06:13,990 --> 00:06:20,450
You get yourself a two dimensional representation and you can see the number.
75
00:06:20,890 --> 00:06:23,560
Let's call it specified here.
76
00:06:23,900 --> 00:06:28,540
You can see also the numbering of each of the rows and each of the columns.
77
00:06:28,570 --> 00:06:30,910
OK, so it's just like an index.
78
00:06:31,270 --> 00:06:38,230
And the numbering here also starts from zero up to the number of rows, minus one.
79
00:06:38,230 --> 00:06:41,200
So zero one two because we have three rows.
80
00:06:41,230 --> 00:06:42,310
You can see just that.
81
00:06:42,310 --> 00:06:49,960
We start from zero and the same goes for a column from zero to three because we have four columns and
82
00:06:50,170 --> 00:06:56,170
regarding how we can access each of the elements and how we can work with each of the elements of these
83
00:06:56,170 --> 00:07:02,490
two dimensional array, it will be pretty much similar to how we can work with one dimensional arrays,
84
00:07:02,830 --> 00:07:05,740
how we have been working with one dimensional arrays.
85
00:07:06,130 --> 00:07:11,980
But that's something that we will cover in the next videos, because for now, I just wanted to show
86
00:07:11,980 --> 00:07:17,650
you how these grid, how these two dimensional array looks like in our programming language.
87
00:07:18,010 --> 00:07:28,960
And basically what I wanted to say to you guys is that this declaration, OK, that we've just created,
88
00:07:30,070 --> 00:07:36,550
we are specifying to the computer with what exact grid we want to work.
89
00:07:36,550 --> 00:07:40,730
So where we will be, where it may be very useful.
90
00:07:40,750 --> 00:07:48,220
OK, so if you wanted to like to play a tic tac toe with some one of these little nice game with X's
91
00:07:48,220 --> 00:07:49,030
and zeroes.
92
00:07:50,200 --> 00:07:56,020
So in this case, you should also specify some greed, OK, maybe three by three or four by four and
93
00:07:56,200 --> 00:07:57,850
maybe even ten by ten.
94
00:07:57,860 --> 00:07:59,110
There is no problem for that.
95
00:07:59,110 --> 00:08:05,950
Right, because if if you have memory to declare it, you can use applications to work with it.
96
00:08:05,960 --> 00:08:12,340
And that's just one example of where these two-dimensional arrays are useful.
97
00:08:12,880 --> 00:08:14,940
Also, think about Excel sheets.
98
00:08:14,950 --> 00:08:19,900
OK, I'm just it's just the overview of the above overview of Excel sheet.
99
00:08:20,080 --> 00:08:25,600
But yours you can see if you've been working with pixels, that you have rows, you have columns, and
100
00:08:25,600 --> 00:08:30,490
it's also some sort of two dimensional grid and two dimensional array.
101
00:08:30,610 --> 00:08:35,380
And basically there are actually a couple of cool things that you can do with Excel.
102
00:08:35,380 --> 00:08:36,730
So get programmatically.
103
00:08:36,730 --> 00:08:44,710
You can just like connect to it into reediting to your two dimensional array of data into like processes
104
00:08:45,040 --> 00:08:50,200
using our programming language, although in our programming language specifically that we learn in
105
00:08:50,200 --> 00:08:56,080
these course, it's not something that is very common, but it's important that you will know that this
106
00:08:56,080 --> 00:08:57,630
thing is also possible.
107
00:08:58,530 --> 00:09:01,560
Who so this is easy for these video guys.
108
00:09:01,570 --> 00:09:03,970
This was a super important video.
109
00:09:04,180 --> 00:09:11,650
I think that's a nice start and a nice and clean introduction to two dimensional array in our C programming
110
00:09:11,650 --> 00:09:12,250
language.
111
00:09:12,730 --> 00:09:14,140
So thank you guys for watching.
112
00:09:14,140 --> 00:09:15,430
And let's move on.
11492
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.