All language subtitles for 4. Challenge 2 - 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, so now once you've given it a try on your own, let's solve this exercise together.

So first of all, we know that the function does not return anything.

So it's going to be a fee void type.

So void.

And now we will specify the function name, let's say Marks Legia.

Right.

Because we find out what is the maximum digit between the digits in a given number.

And of course, we are going to receive as a parameter in other a number.

So in Nahm and now we are going to specify the functions body so the body will have to check out some

condition to make sure that the number E has only two digits.

And one way to do it is to use condition like this.

So we know that all the numbers that have two digits are in the range between 10 and 99.

Right.

Something that is less than ten is contains only one digit.

And something that is above some number that is above 99 contains three numbers at least.

So we are going to write a condition that will check this out.

So if NUM is greater than 99.

Okay.

Let's do it.

This is greater than ninety nine.

Meaning it has three digits or.

Or.

Right.

We are going to use this logical operator to see if another condition may happen.

So if NUM is less than 10, which means that we have only one digit.

So if that's the case we are going to print out a corresponding measure message.

The number, the number is not a two digits number.

Please try again or something like that.

Is that clear?

And now what we are going to do is to specify the L section, which means here are all the interesting

stuff that is going to happen, will be here.

So we want to check out if we have two digits number meaning the number itself.

He has X and Y, let's say X is a digit.

And why is it digits?

Right.

For example, let's say thirty five.

So three is a digit is the left digit than five is the right digit.

So we need to compare between these two digits.

And one way to do so is simply to compare the remainder that you will get.

If you divide the number by ten.

So if you do it like this, you will get.

What is the remainder would be if you divide thirty five by ten.

So if you divide thirty five by ten, you will get three.

Right.

Meaning three times you have multiplied by ten will give you 30.

So the remainder in this case will be just five.

So these division, the remainder of by when you divided by ten will be just five.

Right.

Which give you and which gives you the right digit in these two digits number.

So you compare this one to number divided by ten which gives you.

Which is simply the left digit.

Right.

If we said that we divide thirty five by ten in the full day vision like we can see here will you.

Just three which is the left digit.

So that's how you find out the right digit.

And that's how you find the left digit in a number with two digits.

So if that's the case then we know that the right digit is greater than the left digit.

And in this case, we are going to print out the at the maximum maximum digit in percentage.

The number itself we are going to specify it is percentage.

And instead of the first percentage of the.

We're going to specify.

And in the second percentage, would B, we are going to specify the right digit.

The right digit between the two and the L section is pretty, pretty and pretty much the same.

Because we know that if the left the right digit is not greater than the left, then meaning that the

left is at least equal to or greater than the right.

So we are going to copy and paste this line, this line right here.

And instead of nine divided with the remainder, we are going to divide it just by 10.

And that's basically it.

That's the whole exercise.

A try to summarize it and to make it a little bit faster than the previous ones.

So let's write the main section and make sure that the program works.

OK, so let's test it out just by using mongst digit four thirty five.

And let's see what will be printed out to the screen.

So build and run it.

Let's build and run it.

And we can see that the maximum digit in thirty five is five.

We do another example, let's say 98, whoops, sorry about that.

Let's build in a running once again.

Oh, sorry, sorry, sorry.

We should just modify it here.

So 98.

We are going to see it right here.

OK.

So 98, the maximum digit is nine, of course.

And we can see that a program works, that the function works as expected.

You could write longer are more accurate.

Let's say main program.

Just be reading the value from the user as we've done in the previous challenges.

But that will also be OK for now just to make sure that the function of works.

So to summarize, what we've done here is we simply received a number make made sure that this number

has contains only two digits.

And then we compare at between the right digit.

This is the right digit.

And this is the left digit and printed out a corresponding message based on the result of these conditions.

So thank you guys for watching Gehlen.

I'll see you in the next challenge.

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