Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
OK, so let's solve these exorcize together.
And basically what we want to do is, first of all, to create our two variables in NARM and PEARLED.
So we created two variables that we'll hold for two values that we're expected to receive from the user
a number and its power.
So let's just read them from the user.
Answer a number and then we are going to read these numbers.
So percentage read this number and we are doing also the same for the power.
Enter a power.
All right.
And read it inside of a variable.
Now, what I want us to do is simply to understand that just we we are we cannot use it like this one.
All right.
We cannot use it like percentage.
And here specify Nahm multiplied multiplied by Nahm multiplied by num.
Right.
It simply will not give us the solution that we want.
We want to multiply num by num num just two times.
All right.
Two or three times.
We wanted to be multiplied by num.
How how many times.
The exact time that is specified in this variable minus one.
Okay.
This is the whole structure of the mathematical power operation.
So for that we are going to use loops.
Right.
We are already experts in using loops.
So we should use loops in in order to solve this exercise.
Although there is another way to include some other math library, but we are not familiar with it yet.
So we will just use the tools that we already sell, already studied in this course.
And before we use loops, we should also create some assisting guide variable that will hold the result
so far.
So we will create another variable called int result result.
And we'll just give it a an initial value of one.
And I'm initialize and get by with one because every number in the power of zero will at least give
us one.
Right.
If it's not the power of zero, it will give us one.
If it's nomine the power of one, it will give us num.
So the minimum value is one.
So that's why I'm going with this is our default as our starting point value.
And I want to create a while loop.
So we will use while.
And now we will specify you there of the loop condition.
So as long as po.
All right.
As long as the power is greater than zero.
We are going to execute the Loopt body.
And in the loop, we know that the result will hold the values so far.
Meaning give the power.
Let's say let's take let's take an example.
If num was equal to would be equal to two and the power will equal to three.
We are going to multiply num by that.
Multiplied by now.
Multiplied by num.
So which will look something like that right now.
Multiplied by Nahm, multiplied by narm.
Would you give us two.
Multiplied by two.
Multiplied by two and a total of eight.
So we are going here and we are going to execute this while loop and to add on each iteration the result
of num by number multiplied by num.
And then take this resolved and these value of this multiplication will be inserted in this variable.
And then we are going to repeat this process to take these results so far multiplied by NUM.
And once again, story inside the result variable until until we reach that this condition is false.
So let's see how it looks like we specify the variable resolved equals to the previous result to the
result calculated so far.
All right.
On every duration we multiply by another and another num and multiplied by num.
So the previous result multiplied by num.
You could also write it like this in just less syntax.
Let's say resolved equals two, the previous result multiplied by nine.
This is the same as we've written here.
I think it's more clearer to you guys.
All right.
So now what we want to do, if we will run it like this, we know that the power variable will always
remain as is as we've read it here from the user.
And it will simply be an infinite loop, although nothing will be printed on the screen.
But still, the loop is going to be infinite.
Right.
Because these conditions will always remain true and nothing will kick us out of this loop.
So for that, we will just reduce the power by one on every duration.
Right.
Because if we multiply here num by one, num by num and then by num, once again we know that we are
doing it in the variable power.
Here is three minus one.
Times.
So just a total of two times.
And once we are done, we know that once we are out of this loop of this body loop, we are going to
having the result variable, the result of numb in the power of these given power.
And now all that remains is simply to print out the resolve.
All right.
So let's printing nice nice result of the screen.
So percentage the aid will be the number in the power off and these will be the power that the user
inserted equals to percentage.
All right.
And a backslash.
And at the end.
So here we specify for these first percentages.
We specify a num num.
And then we specify the ball.
And then we specify for this result the result variable.
It now holds the result of all of these calculation.
And now I think we are ready to go with.
I think that we can build and run these programs.
Let's save it and click the build and run button.
All right.
So let's let's try our previous example that we used here, too.
And the power will be three.
So we expect to see the result of two multiplied by two, which is four, and then multiplied once again
by two, which give us a total result of just eight.
So two in the power of zero.
Oh.
What happened here?
Let's see.
So we can see that basically the power that we tried to bring here is now seems to be zero.
Right.
If we run it once again, it doesn't matter which power we insert here.
Let's say five in the power of three.
It still gives us at the end.
Right.
The calculation the result is, OK.
Instead of these percentages, we can see that the number is five.
But still, it gives us the power of zero.
And why is there.
Why is that?
And the reason for that is very simple.
It's because during these while operation, during this wire loop will reduce the value inside of the
power variable on every duration.
So we only leave these wire loop.
When the power equals to zero or it's less than zero.
In Dinara case, it will be just one equals two zero.
So we if we still want to print these nice little message, we should maybe create another variable
that will hold the power itself.
In case that we change the power variable.
Right.
So we can create some in temp timbale that will hold the value of power before we are getting into these
wire loops of tempo temp.
Paul will be equal to now before it has been changed in these while loop in here.
We will also changing to ten ten now.
And now let's try to save it and run and build and running once again.
So two in the power of three.
And we see the exact message that we expect it to in the power of three gives us an eight.
And we also could use it like this one.
Right.
Is the sign which represent in some cases, in some cases, it represents the power in some kulka literacies,
to be more clear.
So if we run it once again, let's do it with five and three.
And we can see that five in the power of three equals two.
One hundred and twenty five.
So this is a four of these video guys.
I think that your calculator is getting more more attractive and with much more functionality to it.
And thank you guys for watching and I'll see you in the next video.
Bye.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.