All language subtitles for 2. Challenge 1 - 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,390 --> 00:00:01,650 All right, welcome back. 2 00:00:01,740 --> 00:00:03,870 Let's try to solve this exercise together. 3 00:00:03,930 --> 00:00:10,290 So first of all, what I want you to notice is what will be the type of these functions? 4 00:00:10,350 --> 00:00:15,570 So we said previously that the function is going to receive two values of a floating point type. 5 00:00:15,600 --> 00:00:23,850 So this function will calculate the area in the area of the flow of the rectangle is just its way multiplied 6 00:00:23,850 --> 00:00:24,840 by its height. 7 00:00:24,870 --> 00:00:25,110 Right. 8 00:00:25,140 --> 00:00:28,500 So two values multiplied, one by another. 9 00:00:28,620 --> 00:00:34,730 And if both of them are are of a floating point type, then the result itself is also to go. 10 00:00:34,870 --> 00:00:37,080 Going to be OWFI floating point. 11 00:00:37,080 --> 00:00:38,340 Floating point type. 12 00:00:38,340 --> 00:00:39,420 Floating point. 13 00:00:40,180 --> 00:00:40,590 OK. 14 00:00:40,830 --> 00:00:47,130 So let's say that the type of this function is going to be float and then we are going to name it as 15 00:00:47,130 --> 00:00:48,390 find area. 16 00:00:48,700 --> 00:00:49,090 OK. 17 00:00:49,530 --> 00:00:52,290 And now it will receive two parameters. 18 00:00:52,290 --> 00:00:53,150 So flowed. 19 00:00:53,820 --> 00:00:58,820 Let's say we weave and float height. 20 00:00:59,650 --> 00:01:02,270 And now we are going to write the functions bodies. 21 00:01:02,280 --> 00:01:04,100 So let's do something like this. 22 00:01:04,110 --> 00:01:09,420 And here we actually going to calculate the area of this rectangle. 23 00:01:09,510 --> 00:01:14,980 So we said that the area may be calculated by multiplying with by each time. 24 00:01:15,040 --> 00:01:20,960 So let's just for simplicity, create another variable and call it and call it area. 25 00:01:21,160 --> 00:01:21,480 Okay. 26 00:01:21,810 --> 00:01:25,020 And we know that area can be calculated by multiplying. 27 00:01:25,320 --> 00:01:26,910 We by height. 28 00:01:27,180 --> 00:01:27,480 Right. 29 00:01:27,630 --> 00:01:28,560 Nothing complicated. 30 00:01:29,400 --> 00:01:35,160 And and we are going to print the result of the screen or just return it. 31 00:01:35,250 --> 00:01:37,530 And this is specified in the question itself. 32 00:01:37,560 --> 00:01:41,540 We are just going to return the area without printing it. 33 00:01:41,790 --> 00:01:48,410 So this function will be responsible for finding out the area and returning it to whoever calls it. 34 00:01:48,440 --> 00:01:50,250 So return area. 35 00:01:50,380 --> 00:01:51,600 Say my goal in the end. 36 00:01:51,720 --> 00:01:54,840 So basically we can say that we are done with this function. 37 00:01:55,090 --> 00:02:00,990 And now what we want to do is to write the main path and see how we can call this function and how we 38 00:02:00,990 --> 00:02:01,680 can use it. 39 00:02:01,710 --> 00:02:04,260 For now, it's just sitting idle here. 40 00:02:04,350 --> 00:02:04,700 Right. 41 00:02:04,740 --> 00:02:09,960 It's some guy that his name is Find Area and he awaits to receive two values. 42 00:02:10,320 --> 00:02:15,400 And once he closes the door in his room, he will find the area and return. 43 00:02:15,450 --> 00:02:20,430 But now it does nothing until we will call him, until we will approach him. 44 00:02:20,520 --> 00:02:22,350 So that's exactly what we are going to do. 45 00:02:22,380 --> 00:02:23,190 The main part. 46 00:02:23,220 --> 00:02:26,010 So, first of all, let's create two variables here. 47 00:02:26,030 --> 00:02:29,350 Let's call it also height and weave. 48 00:02:29,760 --> 00:02:30,180 All right. 49 00:02:30,660 --> 00:02:33,200 Let's do them something like height. 50 00:02:33,510 --> 00:02:36,500 Rectangle, rectangle and weave. 51 00:02:36,810 --> 00:02:38,140 Rick single. 52 00:02:38,550 --> 00:02:38,940 All right. 53 00:02:39,540 --> 00:02:43,800 I'm just using a slightly different name here in the main function. 54 00:02:43,830 --> 00:02:47,010 And in the with in the in defined area function. 55 00:02:47,310 --> 00:02:55,310 Because I want you to to to see that basically these variables here are local to them. 56 00:02:55,440 --> 00:03:01,570 The main function in these variables with in height that these functional receives as parameters are 57 00:03:01,590 --> 00:03:03,540 local to the find area function. 58 00:03:03,600 --> 00:03:05,160 They are not the same. 59 00:03:05,290 --> 00:03:05,550 OK. 60 00:03:05,640 --> 00:03:13,410 We will talk about it more in the advanced sections where we are going to work with pointers and see 61 00:03:13,410 --> 00:03:16,590 how we pass by value and pass by reference. 62 00:03:16,620 --> 00:03:18,540 But that's for another section. 63 00:03:18,780 --> 00:03:21,530 So now let's read these values from the user. 64 00:03:21,540 --> 00:03:24,370 So print f enter with that. 65 00:03:25,100 --> 00:03:25,470 OK. 66 00:03:26,430 --> 00:03:28,190 And the user is going to answer. 67 00:03:28,260 --> 00:03:29,030 He is square. 68 00:03:29,250 --> 00:03:36,560 So percentage de and read the inside the single rectangle. 69 00:03:36,600 --> 00:03:38,090 Why doesn't he total complete me. 70 00:03:38,250 --> 00:03:38,710 OK. 71 00:03:38,760 --> 00:03:41,290 And the same we are going to do for their height. 72 00:03:41,340 --> 00:03:43,120 So answer height. 73 00:03:43,380 --> 00:03:45,330 Right now. 74 00:03:45,330 --> 00:03:48,070 Scarn f gonif percentage. 75 00:03:48,130 --> 00:03:49,460 Knee height. 76 00:03:49,730 --> 00:03:50,160 Height. 77 00:03:51,000 --> 00:03:51,800 Rectangle. 78 00:03:52,140 --> 00:03:52,980 Tingle. 79 00:03:53,430 --> 00:03:54,690 Semicolon at the end. 80 00:03:54,900 --> 00:03:55,980 And there you go. 81 00:03:56,280 --> 00:04:01,500 So at this point we should have the both of these variables with and height. 82 00:04:01,980 --> 00:04:04,680 And now what we want to do is to create. 83 00:04:04,740 --> 00:04:05,210 Oh we. 84 00:04:05,590 --> 00:04:06,290 Sorry about that. 85 00:04:06,300 --> 00:04:09,300 We said that these values are going to be a free floating point. 86 00:04:09,300 --> 00:04:13,450 So just change it to float in here instead of percentage. 87 00:04:13,680 --> 00:04:14,820 Just use percentage. 88 00:04:14,850 --> 00:04:16,080 F in percentage. 89 00:04:16,170 --> 00:04:16,470 F. 90 00:04:16,690 --> 00:04:21,960 Now what we want to do is to run this function, to use this function. 91 00:04:22,350 --> 00:04:27,990 But we know that this function will return something and we want to store the result of this function 92 00:04:27,990 --> 00:04:28,710 will return. 93 00:04:28,950 --> 00:04:33,510 So we'll just create another variable and call it a float area. 94 00:04:33,670 --> 00:04:34,040 Okay. 95 00:04:34,940 --> 00:04:37,690 And now let's just use the function. 96 00:04:37,740 --> 00:04:41,000 So area equals to find area. 97 00:04:41,040 --> 00:04:42,050 Find area. 98 00:04:42,600 --> 00:04:44,360 And we will pass as arguments. 99 00:04:44,400 --> 00:04:45,520 These two values. 100 00:04:45,540 --> 00:04:47,200 So first of all, rule plus this one. 101 00:04:47,580 --> 00:04:49,890 And the second one is the height. 102 00:04:51,060 --> 00:04:51,460 All right. 103 00:04:51,480 --> 00:04:56,240 So now we know that this line at line 22. 104 00:04:56,640 --> 00:04:58,800 We are calling the find area function. 105 00:04:59,070 --> 00:04:59,910 These line. 106 00:05:00,030 --> 00:05:07,030 Are executed and the result returned and assigned store the inside of this area variable. 107 00:05:07,290 --> 00:05:16,560 And if you would like to print the area now, you're going to print the area, the area of your given 108 00:05:16,560 --> 00:05:17,580 rectangle. 109 00:05:17,820 --> 00:05:24,150 Is there a centage percentage half and backslash? 110 00:05:24,210 --> 00:05:28,920 And at the end now, instead of this percentage effort, we are going to specify area. 111 00:05:29,100 --> 00:05:29,910 Is that clear? 112 00:05:30,030 --> 00:05:32,370 So let's try to build and run it. 113 00:05:32,610 --> 00:05:33,720 Let's see an example. 114 00:05:33,720 --> 00:05:35,600 So, oh, what happened? 115 00:05:35,730 --> 00:05:37,350 Nothing really happened. 116 00:05:37,560 --> 00:05:38,610 Why is that? 117 00:05:38,790 --> 00:05:40,500 Why is that so? 118 00:05:40,500 --> 00:05:41,110 No worries. 119 00:05:41,130 --> 00:05:43,290 Guys, I found out what was the problem. 120 00:05:43,300 --> 00:05:49,200 It's nothing related to you because I actually had a couple of other lessons here. 121 00:05:49,200 --> 00:05:56,460 I had less than six, which I was recording also for you, and it was trying to build this last one 122 00:05:56,460 --> 00:05:57,900 instead of this one. 123 00:05:57,900 --> 00:06:02,650 So I fixed it up and we are ready to move on and try to build and run it once again. 124 00:06:02,760 --> 00:06:04,920 So let's press build and run. 125 00:06:05,430 --> 00:06:14,200 So enter with, let's say, five point zero and the height is going to be something like two point five. 126 00:06:14,550 --> 00:06:20,880 So what we expect to receive here is basically we expect these mass edge of the area for your given 127 00:06:20,880 --> 00:06:21,910 rectangle is. 128 00:06:22,220 --> 00:06:26,690 And we expect the result of multiplying five by 2.5. 129 00:06:26,760 --> 00:06:31,290 And the result expected is twin twelve point five. 130 00:06:31,320 --> 00:06:32,310 If I'm not mistaken. 131 00:06:32,670 --> 00:06:36,090 So that's what we expect to receive and to see on the console. 132 00:06:36,600 --> 00:06:43,140 So we if we press answer, we are going to see these scary numbers right here. 133 00:06:43,650 --> 00:06:45,990 And what what do they mean and where are they? 134 00:06:45,990 --> 00:06:46,770 They come from. 135 00:06:47,310 --> 00:06:56,910 And as you may be, if you were pretty much into this lesson your got you were about to see that this 136 00:06:57,030 --> 00:07:04,140 ain't is the whole problem behind it, because we create two variables of an integer type and then read 137 00:07:04,140 --> 00:07:07,320 from the user the inner values as they were a floating point. 138 00:07:07,350 --> 00:07:08,760 So what do we have to fix? 139 00:07:08,760 --> 00:07:10,360 Here is just these lines. 140 00:07:10,410 --> 00:07:16,410 So float, float, change, these type of variables to be a float and now we can build in running once 141 00:07:16,410 --> 00:07:16,740 again. 142 00:07:17,010 --> 00:07:26,040 So 2.5 and five dot zero, we get twelve point five, which is the rectangle of this area. 143 00:07:26,070 --> 00:07:31,320 So we can find the area for any given a rectangle that we will receive from the user. 144 00:07:31,320 --> 00:07:36,420 We just need to receive the dimensions and we can provide this functionality, which is pretty cool, 145 00:07:36,420 --> 00:07:36,740 right? 146 00:07:36,870 --> 00:07:45,750 We can give these program to any student at high school which which struggles with his exams, and it 147 00:07:45,750 --> 00:07:46,860 will help him a lot. 148 00:07:47,400 --> 00:07:48,270 I'm just kidding, guys. 149 00:07:48,720 --> 00:07:50,760 So thank you so, so much for watching. 150 00:07:50,760 --> 00:07:52,020 And I'll see you in the next video. 12111

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