All language subtitles for 17. Challenge 4 - 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

So we already know the logic behind this exercise because previously we already solved it by just by

using globes.

Right.

And all that we have to do now is to change the structure of the loop and to use instead of a while

loop.

We have to use a for a loop.

So let's create or two variables.

The number itself.

So int num count the power power.

And also we need to create another variable that will hold the final result and will help us with the

calculations in the loop.

And this variable will be of course, the results.

So into resolve.

Equals two one.

And in the previous challenge we explained why this.

This our variable.

This result.

Initialize the value of ones.

And if you don't remember.

Go back to the previous challenge and make sure you get the whole idea behind it.

And now let's also create the variable.

I, i.

So tie and this variable is required for us.

So when we are going to use the for loop.

So we're creating this variable that will help us using the for loop structure in C..

All right.

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

So enter Nahm pretty much the same as we've done previously.

Enter NARM.

Then we are going to scan F percentage D and put it inside Nahm.

And the same we are going to do also for the power and her power.

I guess I'm typing a little bit faster than it would be for just copy and paste.

And then I need to change it.

So yeah, I think it is even better and actually it's more safe.

So we are using it in this way.

We are reading the first number.

Then we are reading the power.

And now what we are going to do is to get down to our loop.

And the first thing that you have to do is write the for a statement.

Then you are going to specify there are the initialization of the variable.

I will write this.

This.

Let's put it to be.

I equals to one.

These line these command will be executed only once when we reach this line.

The line fifteen for the first time.

This line will not be executed every time on every duration.

All right.

Only the first time.

This is the initialization section of these for a loop.

So we initially want to be equals to one.

And then we are going to specify, let's specify the condition until when we are going to execute this

loop.

So until we reach I is less than or equal as to the power.

And every time on every duration, every time when every iteration, we are going to increment I by

one.

So the same way as we've done previously with the wire loops, just that.

Now we are writing in for a loop structure.

So here is the first thing you channelization.

This line will be executed on every end of every duration.

So we are going to execute, first of all, the loop body.

Here is going to be the loop body once it's executed.

You are going to run this command.

And if you want to execute the loop body on every duration before you enter the loop, buddy, you are

going to make sure that this condition is satisfied and the result of it is true.

So as long as I as long as I is less than the power entered by the user, we are going to execute this

loop body.

And then the loop body itself is going to be pretty straightforward.

We are just going to use result.

Equals the result.

This is the previous result.

This is the new result that we are going to receive.

So the previous result multiplied by NUM.

Right.

Every time we multiply num by num, multiplied by Nahm and so on and we keep the current result.

And then we multiply the current result by now to get a new updated result.

That's how the power mathematical function works.

So on each iteration, on each iteration, we are going to multiplied, then increase the UI by one

check.

That the condition is satisfied.

And then run the look body once again until we reach some time that these condition happens to be false.

All right.

So now all that we have to do is once we get out of this slope, is just to bring the result in, just

like we did it previously.

Let's use something like this printout percentage.

The.

This is the number in the power.

In the power.

Right.

It was something like this off percentage, the equals to percentage, Dean.

And that's actually what the calculator is given you.

Just not reading like this is percentage D and the power of percent the G equals to the result itself.

And here we are going to specify the values that are going to be placed instead of these percentage

D.

Right.

Instead of these place holders.

So first of all, comes the NUM.

Then we.

All and then we have the result of them, which is held in the result variable.

And there you go.

You can build an Bromley's program to make sure that it works.

So let's do it.

Let's save it and build and run it.

Oh, hey, here we go.

Oh.

So here we have an error.

Let's see what it what it says.

Let's see what it says.

And you can see here, if you take a closer look at that in line fifteen, we are trying to use Pough

variable, which is undeclared.

Why is it undeclared?

Oh, because we defined it as power and not power.

So let's just modified to be something like that.

OK.

So now we have Bao Bao Bao.

Previously we used power.

If we used here power, we didn't specify.

We didn't declare this variable nowhere because it was just power.

And it's a totally different variable.

Right.

It's sname it's not the same and totally the compiler does not understand what we want.

So now let's try to run, build and run it.

So build and run and let's make our previous examples.

So two in the power of three should give us eight.

So let's press answering.

Two in the power of three gives us eight.

And also we can make sure that five in the power of five in the power of five.

Let's see.

It should be.

Yeah, it should be something like that.

So this is it for these video guys.

And the whole point was just to show you that we can solve the same task, find the numbering the Bowery

are given.

Given a numbering in its power.

We can solve it in two different ways, using the while loops or the four loops.

Both of them solve this exercise, but you should go with just one of them in this case.

In this type of challenges.

And which one of them should it be?

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