All language subtitles for 6. Print the Multiplication Table of a number - Solution

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
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
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian Download
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,730 --> 00:00:07,090 All right, so what do you have to do in this exercise, in this exercise, what you have to do is just 2 00:00:07,090 --> 00:00:16,060 to use some sort of, let's say, multiplication table for a given number and a multiplication table 3 00:00:16,060 --> 00:00:18,220 for a given number is very simple. 4 00:00:18,220 --> 00:00:25,270 And it will be divided in our solution into two main steps, that the first step will be simply to receive 5 00:00:25,600 --> 00:00:26,220 one number. 6 00:00:26,450 --> 00:00:33,550 OK, just received some number and print all of the results from one up to 10. 7 00:00:33,580 --> 00:00:36,280 OK, just another multiplied by one print. 8 00:00:36,310 --> 00:00:42,570 The result take two multiplied by num and print the result and so on up until 10. 9 00:00:42,910 --> 00:00:51,530 Nothing complicated, but basically that's the main steps that we will need to do in this kind of solution. 10 00:00:52,060 --> 00:00:56,310 So for that, let's first of all create the variable number. 11 00:00:56,590 --> 00:00:58,750 OK, just the usual process. 12 00:00:58,750 --> 00:01:07,810 Let's print a nice message, enter num, read the noun value from the user, and later on let's think 13 00:01:07,810 --> 00:01:08,650 about the solution. 14 00:01:08,650 --> 00:01:13,270 What should be the trivial solution for this example, for this step. 15 00:01:14,020 --> 00:01:19,420 So if you are not familiar with loops, probably what you are going to do something like that. 16 00:01:19,420 --> 00:01:19,650 Right? 17 00:01:19,660 --> 00:01:23,530 We know that we will need like 10 printing operations. 18 00:01:23,530 --> 00:01:27,880 So print out and it will be, I don't know, percentage. 19 00:01:27,880 --> 00:01:33,290 The multiplied by one equals two percentage gain. 20 00:01:33,340 --> 00:01:34,020 There you go. 21 00:01:34,030 --> 00:01:36,940 And instead of the first percentage, then we will simply use. 22 00:01:38,170 --> 00:01:40,780 And here we will use num multiplied by one. 23 00:01:40,990 --> 00:01:41,430 OK. 24 00:01:41,470 --> 00:01:42,630 Is that clear so far. 25 00:01:43,480 --> 00:01:48,940 So we simply use these multiplication and let's now just copy it ten times. 26 00:01:49,300 --> 00:01:49,630 Right. 27 00:01:49,630 --> 00:01:52,900 And just I just want to show you guys how it can be done. 28 00:01:52,910 --> 00:01:58,690 So two, three, four, five, six, seven, eight, nine and 10. 29 00:01:59,350 --> 00:02:09,820 And again, here are two, three, four, five, six, seven, eight, nine and ten. 30 00:02:10,390 --> 00:02:14,600 OK, so we simply use 10 percent of lines to bring the result. 31 00:02:15,430 --> 00:02:18,130 So let's try to build and run it. 32 00:02:18,500 --> 00:02:19,630 Let's see if it works. 33 00:02:20,680 --> 00:02:22,520 So enter number three. 34 00:02:23,260 --> 00:02:25,030 OK, what what do you. 35 00:02:25,390 --> 00:02:26,940 What did we forget? 36 00:02:26,950 --> 00:02:28,540 We forgot a new line. 37 00:02:28,540 --> 00:02:29,800 So backslash in here. 38 00:02:30,220 --> 00:02:31,300 Let's copy it. 39 00:02:31,300 --> 00:02:36,460 Backslash, backslash and backslash and so on. 40 00:02:36,460 --> 00:02:40,360 Just adding the next list and character that Adam that Adam. 41 00:02:40,360 --> 00:02:42,460 And now let's build and run it once again. 42 00:02:42,640 --> 00:02:45,920 So enter now three and yeah, awesome. 43 00:02:45,940 --> 00:02:47,920 It seems to be working correctly. 44 00:02:47,950 --> 00:02:56,800 We simply print all the values of these multiplication table four of these given number three in this 45 00:02:56,800 --> 00:02:57,190 case. 46 00:02:57,190 --> 00:03:01,840 So three multiplied by one, three multiplied by two, three multiplied by three and so on. 47 00:03:02,140 --> 00:03:04,750 Up until three multiplied by ten. 48 00:03:05,680 --> 00:03:13,390 And of course, this solution works OK, and there is no problem with that, but that was the first 49 00:03:13,390 --> 00:03:17,560 step and it's also optional to use it without the loop, right? 50 00:03:18,010 --> 00:03:19,000 It's also optional. 51 00:03:19,540 --> 00:03:21,250 But the question comes here. 52 00:03:21,640 --> 00:03:28,240 Let's say that we want to upgrade to these programming, to print all the values from multiplying number 53 00:03:28,260 --> 00:03:32,190 by one by two up until ten thousand. 54 00:03:32,710 --> 00:03:34,940 OK, so what will you do, guys? 55 00:03:35,140 --> 00:03:38,560 Will you simply take this and copy that? 56 00:03:38,710 --> 00:03:40,230 I don't know what like this. 57 00:03:40,240 --> 00:03:45,520 Copying it 10000 times and modifying everything manually. 58 00:03:46,080 --> 00:03:47,020 This will work. 59 00:03:47,020 --> 00:03:51,310 But but can you agree that it will be so messy? 60 00:03:51,580 --> 00:03:53,260 It will be so I don't know. 61 00:03:53,300 --> 00:03:58,740 It's so hard to maintain so long it will take you to complete this program. 62 00:03:58,750 --> 00:04:01,440 So I think that's a problem. 63 00:04:01,960 --> 00:04:10,420 And also another problem is that let's say we want to make this step to OK, which says the following 64 00:04:10,420 --> 00:04:14,830 step two, step two will get you will get here now. 65 00:04:15,250 --> 00:04:22,360 And let's say you multiply Chaytor, we'll call it multiplication and you will simply need that. 66 00:04:22,360 --> 00:04:25,790 Your program will print all the values like this. 67 00:04:25,810 --> 00:04:34,690 So now multiplied by one now multiplied by one now multiplied by two up until this given number, multiplied 68 00:04:34,690 --> 00:04:39,880 by these multiplied cater multiply chaytor. 69 00:04:39,940 --> 00:04:44,170 OK, so that's will be that will be a problem. 70 00:04:44,180 --> 00:04:48,580 I don't think that's even possible. 71 00:04:48,820 --> 00:04:55,990 There are a couple of tricks that it can be done, but simply how can you print in advance all the lines 72 00:04:55,990 --> 00:04:58,700 of code up until this multiplication? 73 00:04:58,930 --> 00:05:02,250 You you don't know if it will be five, six, maybe 10. 74 00:05:03,340 --> 00:05:08,560 So the right approach to solve this exercise would be to use the loops. 75 00:05:09,430 --> 00:05:16,660 And if we want to use loops, probably the better idea here will be not to use a do while loop for a 76 00:05:16,960 --> 00:05:19,460 while loop it will be to use for a loop. 77 00:05:19,900 --> 00:05:27,220 So in time, OK, so if we know that we are going to use the for a loop and we know that this loop is 78 00:05:27,220 --> 00:05:34,260 going to start from one up to ten, let's do it just up to ten in this example, the first step. 79 00:05:35,220 --> 00:05:36,780 So from one up to ten. 80 00:05:36,790 --> 00:05:43,300 So we know for I equals to one I is less than or equal to numb. 81 00:05:43,510 --> 00:05:43,960 Right. 82 00:05:43,960 --> 00:05:46,280 Or to ten in this case. 83 00:05:47,020 --> 00:05:54,940 So from one to ten we are going to increment at the end of every iteration I buy one and to print the 84 00:05:54,940 --> 00:05:56,230 results to the screen. 85 00:05:56,230 --> 00:05:59,130 So let's just simply copy that and modify it a little bit. 86 00:05:59,710 --> 00:06:01,020 So it's going to look like this. 87 00:06:01,030 --> 00:06:09,460 So percentage then multiplied by percentage D equals to percentage B, but instead of the first percentage, 88 00:06:09,460 --> 00:06:15,430 do we know it will be NUM instead of the second percentage, instead of the second placeholder, it 89 00:06:15,430 --> 00:06:16,330 will be I. 90 00:06:17,230 --> 00:06:20,600 And finally it will be these percentage. 91 00:06:20,600 --> 00:06:24,250 They will simply print num multiplied by I. 92 00:06:24,700 --> 00:06:33,670 OK, so if basically all of these for a loop and these primitive lines, it's kind of one in the same 93 00:06:33,670 --> 00:06:38,890 thing guys, because you can see instead of these percentage, then the second percentage that we used 94 00:06:38,890 --> 00:06:45,970 here manually to write the number itself and here in the multiplication also now we simply modified 95 00:06:45,970 --> 00:06:49,240 it and we said let's use a placeholder instead of this. 96 00:06:49,450 --> 00:06:57,220 And these placeholder will have the value of EI, which is basically a variable that changes on every 97 00:06:57,220 --> 00:07:01,570 duration and getting increment and by one at the end of every iteration. 98 00:07:02,050 --> 00:07:04,230 So let's try to build and run it. 99 00:07:05,200 --> 00:07:08,280 So go here, build and run internally. 100 00:07:09,100 --> 00:07:10,750 And yeah, there you go. 101 00:07:10,750 --> 00:07:16,750 You can see from one to ten printed all of them inside of the for a loop as part of the for loop. 102 00:07:17,020 --> 00:07:23,360 And also there are from one to ten printed as part of just the printing lines. 103 00:07:23,980 --> 00:07:25,990 So yeah that's amazing. 104 00:07:26,180 --> 00:07:26,950 That's good. 105 00:07:27,370 --> 00:07:35,020 And now what we will have to do is simply first of all let's remove that is to upgrade this program 106 00:07:35,020 --> 00:07:42,580 to support the second step of getting numb and a multiple locator and printing from NUM from one up 107 00:07:42,580 --> 00:07:46,620 to multiplication are all the multiplication table of num. 108 00:07:47,560 --> 00:07:54,880 So let's create additional variable, call it multi, please multiply Keiter. 109 00:07:55,420 --> 00:08:01,520 OK, and these multiplications are also we will get it from the user, so let's use it like this. 110 00:08:01,520 --> 00:08:05,170 So print f enter the multiple. 111 00:08:05,910 --> 00:08:13,790 Dramatically greater and read the value here story inside of this variable, and now the only thing 112 00:08:13,790 --> 00:08:21,170 that will do that we will need to modify for the second step is just this stopping condition of the 113 00:08:21,170 --> 00:08:21,750 for loop. 114 00:08:22,220 --> 00:08:31,280 So now, instead of executing all of the multiplication operations, we will up until 10, we will just 115 00:08:31,280 --> 00:08:33,830 modify it and use here and multiply Katar. 116 00:08:34,220 --> 00:08:38,930 That will basically specify what will be the stopping condition. 117 00:08:39,750 --> 00:08:47,750 So let's just show an example and let's say that was the problem multiplied Kether, multiply Chaytor. 118 00:08:48,300 --> 00:08:50,940 OK, so what is the problem? 119 00:08:50,940 --> 00:08:54,670 Let's see, multiplications are undeclared. 120 00:08:55,350 --> 00:08:56,730 Why is it undeclared? 121 00:08:56,820 --> 00:09:03,910 Multiple Chaytor Because it's more mollet multiplication or it should be OK. 122 00:09:03,960 --> 00:09:04,950 So now it should work. 123 00:09:05,340 --> 00:09:07,130 So let's just call this one. 124 00:09:07,150 --> 00:09:08,360 I don't like it here. 125 00:09:08,370 --> 00:09:09,180 Let's close it. 126 00:09:09,180 --> 00:09:10,380 Let's build and run it. 127 00:09:10,980 --> 00:09:13,450 And what's going on. 128 00:09:13,500 --> 00:09:14,230 OK. 129 00:09:14,400 --> 00:09:16,140 So here is our council. 130 00:09:16,140 --> 00:09:17,310 Enter Annam three. 131 00:09:17,610 --> 00:09:19,110 Enter the multiplication. 132 00:09:19,280 --> 00:09:20,490 Let's go with 12. 133 00:09:21,150 --> 00:09:23,310 So three multiplied by one. 134 00:09:23,310 --> 00:09:23,760 By two. 135 00:09:23,760 --> 00:09:25,290 By three by whatever. 136 00:09:25,440 --> 00:09:32,100 You print all the multiplication table of a given number up until a given multiplication. 137 00:09:32,130 --> 00:09:37,320 So let's say we wanted to go with five and we wanted to print all the values. 138 00:09:37,950 --> 00:09:42,480 Five multiplied by one by two up until, let's say a thousand. 139 00:09:43,530 --> 00:09:44,250 A thousand. 140 00:09:44,280 --> 00:09:47,810 So it goes like this multiplied by a thousand. 141 00:09:48,150 --> 00:09:52,200 So you can see all of the printing lines of code or game console. 142 00:09:52,200 --> 00:09:56,610 They didn't show it, but all the printing operations are actually there. 143 00:09:56,610 --> 00:10:02,790 And you just print all the values of these given no up until your multiplication. 144 00:10:03,330 --> 00:10:10,910 And yeah, that's basically a part of bigger programs that use multiplications and use multiplication. 145 00:10:11,610 --> 00:10:14,520 And yeah, I think this is through these video. 146 00:10:14,520 --> 00:10:16,710 Guys, thank you so much for your attention. 147 00:10:16,740 --> 00:10:20,070 Keep them practicing and you are bound to succeed. 148 00:10:20,340 --> 00:10:21,270 I'll see you next time. 13514

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