All language subtitles for 4. Exercise 1 - Initializing & Printing 2D Array

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian Download
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,570 --> 00:00:07,590 OK, guys, so what we are going to do right now is to initialise to the clearing, initialise a two 2 00:00:07,590 --> 00:00:14,820 dimensional array and then print all of its values to make sure that everything is actually as we expected 3 00:00:14,820 --> 00:00:15,180 to be. 4 00:00:15,600 --> 00:00:18,380 So let's first of all, initialize some array. 5 00:00:18,390 --> 00:00:23,470 Let's go within my two 2D array. 6 00:00:23,490 --> 00:00:23,800 OK. 7 00:00:23,820 --> 00:00:32,950 So my two dimensional array and let's go like with two rows and let's make three columns, OK? 8 00:00:32,970 --> 00:00:34,100 Doesn't really matter. 9 00:00:34,620 --> 00:00:37,290 And now we are going to also specify its values. 10 00:00:37,320 --> 00:00:41,730 So we know that we have here two rows in three columns. 11 00:00:41,730 --> 00:00:48,420 And for the first row we will specify the values like let's say one, five and nine. 12 00:00:48,780 --> 00:00:54,310 And for the second column, we are going to use just even only even numbers. 13 00:00:54,330 --> 00:00:58,680 So it's going to be like, let's say two, six and 10. 14 00:00:58,710 --> 00:01:04,020 OK, so that's how we are going to feel, our new two dimensional array. 15 00:01:04,180 --> 00:01:07,500 Now, what we have to do is print all of its values. 16 00:01:07,500 --> 00:01:12,210 So how basically should you approach this task? 17 00:01:12,960 --> 00:01:20,160 So one of the things to do here is to understand that we are working with a two dimensional array and 18 00:01:20,160 --> 00:01:25,380 he'd have to access it has rows and it has columns. 19 00:01:25,860 --> 00:01:32,910 So what we will have to do is to iterate over all the rows, OK, over all the rows. 20 00:01:32,940 --> 00:01:36,420 So meaning we will need to create some additional variable. 21 00:01:36,420 --> 00:01:40,140 I will need to iterate over all the rows. 22 00:01:40,150 --> 00:01:45,060 So for I equals to zero I less than two. 23 00:01:45,100 --> 00:01:45,470 Right. 24 00:01:45,480 --> 00:01:47,450 We have here only two rows. 25 00:01:47,820 --> 00:01:55,890 We are going to iterate over all the two rows and rows zero and it's row one and of course C++ to incremented 26 00:01:56,310 --> 00:01:57,540 for the duration. 27 00:01:57,840 --> 00:02:07,200 And for every row that we are going to iterate we need also like when we worked in print, one dimensional 28 00:02:07,200 --> 00:02:07,590 arrays. 29 00:02:07,590 --> 00:02:15,900 We need to print every value in this row, meaning we need to pass over all the columns in this given 30 00:02:15,900 --> 00:02:16,560 row. 31 00:02:16,570 --> 00:02:24,600 So we will need additional inside loop, OK, and nested loop that will iterate over all the elements 32 00:02:24,600 --> 00:02:26,310 for each given row. 33 00:02:26,640 --> 00:02:33,260 So for that, we will use additional, let's say, the assisting variable colleague J. 34 00:02:33,840 --> 00:02:36,570 And we will use here this internal for a loop. 35 00:02:36,570 --> 00:02:38,960 So it will be like this. 36 00:02:38,970 --> 00:02:48,210 So for J equals to zero as long as J is less than three, because we have here the number of columns 37 00:02:48,210 --> 00:02:51,450 is three and on every duration plus. 38 00:02:51,450 --> 00:03:00,030 Plus meaning what does it mean, this internal or nested loop we have here, the outside loop which 39 00:03:00,030 --> 00:03:06,210 basically says that go over all of the rows. 40 00:03:06,480 --> 00:03:08,960 OK, one by one, one by one. 41 00:03:09,840 --> 00:03:10,670 And here. 42 00:03:10,680 --> 00:03:12,150 OK, let's use it like this. 43 00:03:12,150 --> 00:03:17,340 I like this representation the most one by one in here. 44 00:03:17,370 --> 00:03:18,360 Go over. 45 00:03:18,510 --> 00:03:26,940 Go over all of it columns, all the columns of a given row that you are already in. 46 00:03:26,970 --> 00:03:31,680 So for the first row, ok, I equals to zero. 47 00:03:31,710 --> 00:03:39,120 We are going to iterate over all of its columns and then we are going to print each and every one of 48 00:03:39,120 --> 00:03:40,470 these elements. 49 00:03:40,500 --> 00:03:47,010 So basically the only thing that remains to do here is just to like, OK, what happened? 50 00:03:47,010 --> 00:03:47,970 Why is that these. 51 00:03:48,070 --> 00:03:48,360 Wait. 52 00:03:48,730 --> 00:03:53,160 OK, so let me just fix this one for you. 53 00:03:54,630 --> 00:03:55,030 OK. 54 00:03:55,050 --> 00:03:57,560 So all very strange. 55 00:03:57,570 --> 00:03:58,680 OK, so never mind. 56 00:03:58,680 --> 00:04:03,200 I will just use a tab to move it here like this. 57 00:04:03,240 --> 00:04:09,330 OK, so we are going to use print F into print the value of these rows of percentage. 58 00:04:10,110 --> 00:04:17,240 OK, let's leave some space here and also specify the value in what will be the value. 59 00:04:17,250 --> 00:04:24,120 It will be my two dimensional array at index what index it what row at row I and it. 60 00:04:24,120 --> 00:04:25,140 What column it. 61 00:04:25,140 --> 00:04:26,460 Column J. 62 00:04:26,470 --> 00:04:27,510 And that's it. 63 00:04:27,510 --> 00:04:30,840 That's how we are going to iterate over everything here. 64 00:04:31,320 --> 00:04:33,030 So let's just use here. 65 00:04:33,570 --> 00:04:37,940 OK, never mind, let's just try to build and run it. 66 00:04:37,950 --> 00:04:40,680 So go here, build and run Lola. 67 00:04:40,680 --> 00:04:48,030 And what we can see here, basically what you can see is that all the values were printed one after 68 00:04:48,030 --> 00:04:48,570 the other. 69 00:04:48,570 --> 00:04:54,690 So one five nine, which is the exact ichi's, which is exactly our first row. 70 00:04:54,960 --> 00:04:59,010 And then you have to 610, which is exactly the second row. 71 00:04:59,730 --> 00:04:59,850 It's. 72 00:04:59,910 --> 00:05:10,280 Once again, we iterated over all the rows by taking one row and iterating and printing all of its values, 73 00:05:10,530 --> 00:05:17,760 going over all of its columns, and basically once we are done with one row, we incremented, I buy 74 00:05:17,760 --> 00:05:20,190 one and we moved to the next row. 75 00:05:20,610 --> 00:05:23,010 So I want to print these. 76 00:05:23,010 --> 00:05:29,010 Instead of just pointing it out in one line, I want to print it out in like, you know, kind of a 77 00:05:29,010 --> 00:05:34,510 grid, like we think about two dimensional array with rows and columns. 78 00:05:34,590 --> 00:05:42,960 So one way to do so is to understand that on every every row, once we've done printing all the values 79 00:05:42,960 --> 00:05:45,890 for a given row, we would like to print a new line. 80 00:05:45,900 --> 00:05:53,040 So print out and here, just use backslash N and let's see what happens now. 81 00:05:53,070 --> 00:05:54,540 OK, so build and run it. 82 00:05:54,540 --> 00:05:58,310 And what you will see is that nothing happened. 83 00:05:58,620 --> 00:06:00,060 So why is that? 84 00:06:00,270 --> 00:06:07,980 We can see only after after we have exited these for a loop at the end. 85 00:06:08,280 --> 00:06:10,360 So just a new line before the return. 86 00:06:10,380 --> 00:06:11,790 So what was the problem? 87 00:06:12,410 --> 00:06:13,980 The problem is very simple. 88 00:06:14,400 --> 00:06:22,110 We didn't use curly brackets to specify that inside of these out for a loop, there will be more than 89 00:06:22,110 --> 00:06:23,080 just one command. 90 00:06:23,100 --> 00:06:27,860 We talked about it when we learned how to use for loops. 91 00:06:28,140 --> 00:06:30,930 So that's how you are going to use it. 92 00:06:30,970 --> 00:06:32,640 OK, so four, four, four. 93 00:06:32,670 --> 00:06:35,530 And also here we are going to close it. 94 00:06:35,790 --> 00:06:41,700 So now these printer line will be under these out outside there are for a loop. 95 00:06:41,970 --> 00:06:43,850 So let's build and run it once again. 96 00:06:44,130 --> 00:06:45,380 And there you go. 97 00:06:45,660 --> 00:06:49,770 We have our two dimensional array printed to the screen. 98 00:06:49,770 --> 00:06:57,300 So you iterate over the first row, like with I equals to zero, go over all of the elements, all of 99 00:06:57,300 --> 00:07:02,910 the columns, print them, then you print enter, you move on to the next line and then you go once 100 00:07:02,910 --> 00:07:03,390 again. 101 00:07:03,420 --> 00:07:07,590 You do so four to six in 10 and then you come here. 102 00:07:07,600 --> 00:07:09,030 You see that I equals two. 103 00:07:09,030 --> 00:07:11,540 Two two is not less than two. 104 00:07:11,580 --> 00:07:19,080 Then the condition this condition is false and you go and return zero to indicate the success of your 105 00:07:19,110 --> 00:07:19,840 program. 106 00:07:20,310 --> 00:07:21,780 So that's it. 107 00:07:22,080 --> 00:07:23,000 That's it guys. 108 00:07:23,280 --> 00:07:29,430 And one thing that I want to ask you is in the previous videos we've seen and I showed you a lot of 109 00:07:29,430 --> 00:07:37,530 examples, not a lot of but a couple of examples with different types of two dimensional arrays and 110 00:07:37,530 --> 00:07:40,760 with different options for initialization. 111 00:07:40,770 --> 00:07:47,820 And what I want to ask you to do is like a little homework, small task, you know how to print all 112 00:07:47,820 --> 00:07:50,460 the values of a two dimensional array now. 113 00:07:50,790 --> 00:07:55,860 So go and initialize these values like you've seen in the previous videos. 114 00:07:56,460 --> 00:08:00,210 Go and like make some hands on, make some practice here. 115 00:08:00,210 --> 00:08:01,510 Instead of these percentage. 116 00:08:01,510 --> 00:08:08,580 They think of what it should be, maybe should be percentage C or percentage F or L F, whatever it 117 00:08:08,580 --> 00:08:15,360 is, and initialize different sizes of of two dimensional arrays use. 118 00:08:15,360 --> 00:08:19,260 Here's one of our three options that we talked about. 119 00:08:19,260 --> 00:08:26,250 Maybe should be like this one five, OK, and build and run it and just work with it and make sure you 120 00:08:26,250 --> 00:08:34,470 understand everything that we spoke about in our previous videos and that you are ready to move on with 121 00:08:34,470 --> 00:08:36,680 our two dimensional arrays. 122 00:08:36,900 --> 00:08:40,950 So thank you guys for watching and I will see you in the next video. 11111

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.