All language subtitles for 2. Challenge 1 - 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
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

Original subtitles

All right, welcome back.

Let's try to solve this exercise together.

So first of all, what I want you to notice is what will be the type of these functions?

So we said previously that the function is going to receive two values of a floating point type.

So this function will calculate the area in the area of the flow of the rectangle is just its way multiplied

by its height.

Right.

So two values multiplied, one by another.

And if both of them are are of a floating point type, then the result itself is also to go.

Going to be OWFI floating point.

Floating point type.

Floating point.

OK.

So let's say that the type of this function is going to be float and then we are going to name it as

find area.

OK.

And now it will receive two parameters.

So flowed.

Let's say we weave and float height.

And now we are going to write the functions bodies.

So let's do something like this.

And here we actually going to calculate the area of this rectangle.

So we said that the area may be calculated by multiplying with by each time.

So let's just for simplicity, create another variable and call it and call it area.

Okay.

And we know that area can be calculated by multiplying.

We by height.

Right.

Nothing complicated.

And and we are going to print the result of the screen or just return it.

And this is specified in the question itself.

We are just going to return the area without printing it.

So this function will be responsible for finding out the area and returning it to whoever calls it.

So return area.

Say my goal in the end.

So basically we can say that we are done with this function.

And now what we want to do is to write the main path and see how we can call this function and how we

can use it.

For now, it's just sitting idle here.

Right.

It's some guy that his name is Find Area and he awaits to receive two values.

And once he closes the door in his room, he will find the area and return.

But now it does nothing until we will call him, until we will approach him.

So that's exactly what we are going to do.

The main part.

So, first of all, let's create two variables here.

Let's call it also height and weave.

All right.

Let's do them something like height.

Rectangle, rectangle and weave.

Rick single.

All right.

I'm just using a slightly different name here in the main function.

And in the with in the in defined area function.

Because I want you to to to see that basically these variables here are local to them.

The main function in these variables with in height that these functional receives as parameters are

local to the find area function.

They are not the same.

OK.

We will talk about it more in the advanced sections where we are going to work with pointers and see

how we pass by value and pass by reference.

But that's for another section.

So now let's read these values from the user.

So print f enter with that.

OK.

And the user is going to answer.

He is square.

So percentage de and read the inside the single rectangle.

Why doesn't he total complete me.

OK.

And the same we are going to do for their height.

So answer height.

Right now.

Scarn f gonif percentage.

Knee height.

Height.

Rectangle.

Tingle.

Semicolon at the end.

And there you go.

So at this point we should have the both of these variables with and height.

And now what we want to do is to create.

Oh we.

Sorry about that.

We said that these values are going to be a free floating point.

So just change it to float in here instead of percentage.

Just use percentage.

F in percentage.

F.

Now what we want to do is to run this function, to use this function.

But we know that this function will return something and we want to store the result of this function

will return.

So we'll just create another variable and call it a float area.

Okay.

And now let's just use the function.

So area equals to find area.

Find area.

And we will pass as arguments.

These two values.

So first of all, rule plus this one.

And the second one is the height.

All right.

So now we know that this line at line 22.

We are calling the find area function.

These line.

Are executed and the result returned and assigned store the inside of this area variable.

And if you would like to print the area now, you're going to print the area, the area of your given

rectangle.

Is there a centage percentage half and backslash?

And at the end now, instead of this percentage effort, we are going to specify area.

Is that clear?

So let's try to build and run it.

Let's see an example.

So, oh, what happened?

Nothing really happened.

Why is that?

Why is that so?

No worries.

Guys, I found out what was the problem.

It's nothing related to you because I actually had a couple of other lessons here.

I had less than six, which I was recording also for you, and it was trying to build this last one

instead of this one.

So I fixed it up and we are ready to move on and try to build and run it once again.

So let's press build and run.

So enter with, let's say, five point zero and the height is going to be something like two point five.

So what we expect to receive here is basically we expect these mass edge of the area for your given

rectangle is.

And we expect the result of multiplying five by 2.5.

And the result expected is twin twelve point five.

If I'm not mistaken.

So that's what we expect to receive and to see on the console.

So we if we press answer, we are going to see these scary numbers right here.

And what what do they mean and where are they?

They come from.

And as you may be, if you were pretty much into this lesson your got you were about to see that this

ain't is the whole problem behind it, because we create two variables of an integer type and then read

from the user the inner values as they were a floating point.

So what do we have to fix?

Here is just these lines.

So float, float, change, these type of variables to be a float and now we can build in running once

again.

So 2.5 and five dot zero, we get twelve point five, which is the rectangle of this area.

So we can find the area for any given a rectangle that we will receive from the user.

We just need to receive the dimensions and we can provide this functionality, which is pretty cool,

right?

We can give these program to any student at high school which which struggles with his exams, and it

will help him a lot.

I'm just kidding, guys.

So thank you so, so much for watching.

And I'll see you in the next video.

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