All language subtitles for 5. Exercise 2 - Multiplication Table - Solution

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,180 --> 00:00:07,230 Oh, wow, that's a nice example in this exercise, what we are going to do is to write some code that 2 00:00:07,230 --> 00:00:14,490 is responsible for printing the multiplication table, just like the one you've learned when you were 3 00:00:14,490 --> 00:00:17,310 about six or seven years old. 4 00:00:17,880 --> 00:00:24,820 And we are going to write this multiplication table from one to ten, I think will be enough. 5 00:00:24,840 --> 00:00:27,420 OK, so that's what we are going to do. 6 00:00:27,420 --> 00:00:34,150 And we are going to solve this exercise by using none other than our two dimensional array. 7 00:00:34,170 --> 00:00:36,410 So I hope you're ready and let's go. 8 00:00:36,780 --> 00:00:41,280 And first thing that we have to do here is to define some size. 9 00:00:41,310 --> 00:00:45,370 OK, so let's give here like a size, OK? 10 00:00:45,480 --> 00:00:48,360 And the size will be of a size 11. 11 00:00:48,570 --> 00:00:52,620 And I will explain you right away why we use here 11 instead of 10. 12 00:00:53,070 --> 00:01:01,290 And basically, just a quick reminder to you guys, whenever you will see size in our program by using 13 00:01:01,290 --> 00:01:06,240 these define it will be replaced even before the compilation phase. 14 00:01:06,420 --> 00:01:09,460 It will be replaced by the value of eleven. 15 00:01:09,930 --> 00:01:16,740 So since we know that we are going to work with two dimensional arrays, probably we are going to iterate 16 00:01:16,740 --> 00:01:18,860 over each of them ever. 17 00:01:19,590 --> 00:01:22,760 We are going to iterate over the rows and the columns. 18 00:01:22,890 --> 00:01:28,890 So for that, we've seen in the previous exercise that we are going to use and I and J for that. 19 00:01:28,890 --> 00:01:36,960 OK, and also what I want to do is to create or basically initialize our metrics, our two dimensional 20 00:01:36,960 --> 00:01:41,300 array with the size of size by size. 21 00:01:41,310 --> 00:01:49,230 It will be a square square, two dimensional array, just like we would have expected of a multiplication 22 00:01:49,230 --> 00:01:49,820 table. 23 00:01:50,370 --> 00:01:58,260 And now what I want us to do is to started from our equals to zero as long as I is less than size, 24 00:01:58,260 --> 00:02:06,450 iterating over all the rows and now inside it, we are going to iterate over all the columns right so 25 00:02:06,810 --> 00:02:12,630 close to zero G is less than size and J plus plus. 26 00:02:13,140 --> 00:02:20,820 And what we are going to do right now is to specify we are basically going first of all, to feel OK, 27 00:02:20,820 --> 00:02:22,380 so let's call this step. 28 00:02:22,920 --> 00:02:24,300 That will be our first step. 29 00:02:24,330 --> 00:02:26,790 So step number one. 30 00:02:26,790 --> 00:02:33,840 Step one is to feel the values in the table. 31 00:02:34,050 --> 00:02:36,600 OK, so that will be the step one. 32 00:02:37,410 --> 00:02:42,870 And we will feel the values because first of all, now we just declared it right. 33 00:02:42,870 --> 00:02:44,060 It's not initialized. 34 00:02:44,400 --> 00:02:54,450 So we are going to feel the values and we can say that the matrix OK, at Index I j at Index I j meaning 35 00:02:55,770 --> 00:03:04,420 the value of the element at Row II and column J will be equal to I multiplied by J. 36 00:03:04,500 --> 00:03:07,320 OK, that's how the multiplication table works, right. 37 00:03:07,630 --> 00:03:11,590 You take the value from the row and multiplied by the value of the column. 38 00:03:11,790 --> 00:03:13,050 So very simple. 39 00:03:13,530 --> 00:03:20,010 And the only thing that I want to mention here is regarding the size of eleven. 40 00:03:20,460 --> 00:03:24,120 I mean, why would I define it of size 11? 41 00:03:24,200 --> 00:03:31,080 And the reason is very simple, because if we start on both of these of loops from zero, then we know 42 00:03:31,080 --> 00:03:40,350 that we will get like zero values at the leftmost column and the upper row will be also zero is because 43 00:03:40,380 --> 00:03:47,340 everywhere that I is going to be equal to zero in J will be equal to zero, you will simply get a bunch 44 00:03:47,340 --> 00:03:48,530 of zero soon. 45 00:03:48,780 --> 00:03:52,620 You may also try it, but the result will be very disappointing. 46 00:03:52,620 --> 00:03:57,240 But let's let's also give it a shot that you will understand exactly what I meant. 47 00:03:57,390 --> 00:04:00,030 So let us proceed and go like this. 48 00:04:00,030 --> 00:04:09,690 So for OK, now basically we are going to do step two and this step is printing the multiplication table, 49 00:04:10,200 --> 00:04:12,900 multiplication table. 50 00:04:13,320 --> 00:04:14,880 So that's what we are going to do. 51 00:04:14,880 --> 00:04:22,680 So for I equals to zero as long as I is less than this size, I plus plus in here, what we are going 52 00:04:22,680 --> 00:04:29,130 to do is to print these, these two dimensional array just like we've done in the previous video. 53 00:04:29,130 --> 00:04:35,570 So four J equals to zero as long as is less that size J plus plus. 54 00:04:35,880 --> 00:04:43,750 And here we are going to use print F and we are going to specify here percentage and specify the value. 55 00:04:43,770 --> 00:04:45,660 OK, let's just use some space here. 56 00:04:45,720 --> 00:04:47,910 Specify the value of a at index. 57 00:04:47,910 --> 00:04:53,500 I hate index cymatics index I and index J. 58 00:04:53,520 --> 00:04:54,600 OK, row I. 59 00:04:54,600 --> 00:04:57,960 Index wrote a column J and awesome. 60 00:04:57,960 --> 00:04:59,880 And once we are out of these. 61 00:05:00,160 --> 00:05:07,390 Look, we are going to print in your line so that it will look like a real two dimensional matrix and 62 00:05:07,390 --> 00:05:13,460 now what we are going to do is simply to build it and run it and let's see what we have here. 63 00:05:13,750 --> 00:05:21,280 So basically, as you go, you can see here like these kind of two dimensional array, but things are 64 00:05:21,580 --> 00:05:23,580 getting a little bit out of balance here. 65 00:05:23,800 --> 00:05:31,390 So let's just add some R representation here using these four or maybe even maybe even five, we let's 66 00:05:31,390 --> 00:05:34,190 use five that we will see it real nice. 67 00:05:34,210 --> 00:05:36,180 OK, so there you go. 68 00:05:36,190 --> 00:05:38,200 Let's just increase the size. 69 00:05:38,590 --> 00:05:39,320 OK. 70 00:05:39,370 --> 00:05:39,940 Awesome. 71 00:05:39,940 --> 00:05:40,480 Awesome, awesome. 72 00:05:40,810 --> 00:05:41,650 So there you go. 73 00:05:41,650 --> 00:05:43,660 You have your multiplication table. 74 00:05:43,930 --> 00:05:49,420 And one thing that I don't really like here is these zeros and these zeros. 75 00:05:49,420 --> 00:05:55,110 And they happen due to the fact that I start from zero in just hours, from zero. 76 00:05:55,390 --> 00:06:02,650 So what I suggest to do is to start both of them from one and start this also from one. 77 00:06:03,040 --> 00:06:08,500 And this way, if we're building run it, we will see something very, very beautiful. 78 00:06:08,510 --> 00:06:15,940 We will see actually the multiplication table that you have been seeing probably when you was when you 79 00:06:15,940 --> 00:06:18,160 were like six, seven years old. 80 00:06:18,170 --> 00:06:20,200 So one multiplied by one is one. 81 00:06:20,440 --> 00:06:26,170 Two multiplied by one is two, let's say five multiplied by two is ten. 82 00:06:26,170 --> 00:06:29,260 And you go like this, five multiplied by four is twenty. 83 00:06:29,290 --> 00:06:33,460 And you have created your OK, that's yours guys. 84 00:06:34,000 --> 00:06:39,270 You created your first multiplication table and it's actually looking amazing. 85 00:06:39,760 --> 00:06:48,070 And what's what's the best part here is that you can also let's say you wanted like to increase the 86 00:06:48,070 --> 00:06:52,990 size of this multiplication table and let's say you wanted to go like with twenty. 87 00:06:52,990 --> 00:06:58,630 So you will just build and run it and let's increase it to the fullest. 88 00:06:58,640 --> 00:06:59,440 And there you go. 89 00:06:59,440 --> 00:07:05,500 You have a multiplication table of twelve twenty by 20 so you can increase it however you like. 90 00:07:05,500 --> 00:07:12,730 You have two dimensional array, you have a full control of its size, its number of rows and arrows 91 00:07:12,730 --> 00:07:16,570 and you know how to set and to feel its values. 92 00:07:16,570 --> 00:07:20,340 And you also know how to print all of its values. 93 00:07:20,770 --> 00:07:22,270 So pretty awesome. 94 00:07:22,270 --> 00:07:28,150 Guys, I think you are starting to get the feeling of how to work with two dimensional arrays. 95 00:07:28,270 --> 00:07:29,830 That's very important. 96 00:07:30,400 --> 00:07:32,140 It's a very useful topic. 97 00:07:32,140 --> 00:07:36,610 He used a lot in even even even in tech interviews. 98 00:07:36,610 --> 00:07:41,520 And also on your exam, it may be used if you are studying this material in these course. 99 00:07:42,250 --> 00:07:45,280 So I think this is it for these video guys. 100 00:07:45,280 --> 00:07:46,750 Let me know what you think of it. 101 00:07:46,750 --> 00:07:49,570 If you have any questions, feel free to ask. 102 00:07:49,570 --> 00:07:52,630 And until next time, I'll see you there. 9995

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