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
Welcome back.
Alphatech Practice service.
And before we move on, I want to tell you congratulations.
If you made it so far out of these chorus, it means you are on the right path to becoming a better
a much better programmer, as I guess you've probably noticed by now.
Every news section that you start this course is mostly based upon previous ones.
So everything is related and every topic you study is important.
And it's probably going to be used in one of the next sections.
For example, you remember variables when we studied variables and then we used them in the conditions
section as well as using other functions like input and output throughout most of these course and most
of these challenges so far.
And that's a very important note, guys, that I want you to pay attention to, because you see you
are actually not allowed to jump from one section to another or miss any of the sections, because if
you do, you're probably not going to understand anything in the next sections.
I mean, anything at all.
That's why I say once again, you have to take all the challenges to try them to do them during every
section and also once in a while.
Make it quick refreshment of the material.
Learn so far.
So what?
It will be much more effective and easier for you.
So these are just some guidelines of what you should and what you shouldn't do to get the maximum knowledge
and value out of these course.
So I hope you got it.
And now we can go back to our topic and introduce and talk about Loop's and one of the best methods
of explaining this topic.
I think it should be done using some project that we've started previously and we keep on developing
as we go.
And of course, I'm talking about a calculator milestone's we've taken previously.
So previously it was just some basic calculator which supported just basic functionality.
Right.
And now I want us to start perfecting it by adding more functionality, making it more like a real calculator.
But before we move on to do so and before any formal loop's explanations, let us take a look at this
following example.
Suppose that you have to write a program that gets a number as input from the user.
For example, num of type end and then the program has to print num in the power of two and nahm in
the power of three.
So at this point you should already be able to solve these types of questions just with ease.
Right.
And you can give it a try on your ROEN before we proceed.
But we are going to take a quick look and see the way we solve it.
We solve these questions together.
So first of all, we need to include the standard input output, create the main function, and then
we will declare a variable called NUM.
And it will be a feen integer type.
Now let's print a message to the screen to let the user know that we are waiting for him to insert these
number.
And let's take this number that the user inserts and put it inside the num variable in.
What we can do right now is simply to preened the result of nomine the power of two a right.
We make these calculation of NUM multiplied by now and display the result instead of these percentages
percentage D instead of these place holders.
So this will be just the NUM in the power of two.
And similarly, we can print nomine the power of three simply by multiplying num multiplied by num multiplied
by num, which is a total of three.
So far so good.
Right.
We had no problems getting some number from the user and printing its nami the power of two and now
means the power of three.
But since we want to make some more advanced and sophisticated calculator that should know how to calculate
NUM in any power, not just two or three, like we can see in this example, any power that the user
will provide.
Not just now.
I mean, the power of two were nomine, the power of three.
But any power, any power.
I mean, it makes sense that we want these type of functionality, right?
I mean, that's that's an important functionality for our calculator.
We want to give the user the ability to specify not only the number itself, but also the power that
this number will be raised in.
For example, if the user was to provide NOM equals to two and a power of six, then the result will
be narm in the power of six was a total of 64.
That's much better and much more functional and various application, isn't it.
We simply provide here more options and abilities for calculation so we can see if.
We run this program as it is right now.
Right.
We can see an example if we insert a number of five.
All right.
This is NUM.
Then we always are going to receive just naming the square of two and naming the square three.
And that's it.
So let's now answer an important question.
How can we do such a general program that we'll be able to calculate the power of any power, any number
in any given power.
Right.
And added to our functionality.
So take a minute to think about it and try to come up with a solution based on everything we've learned
so far.
So pause the video.
Try to think of the solution.
Write down your code and check if it works on your computer.
And once you're finished, we are going to go over it together here in our nice visual viz. screen.
So now I hope that you tried this exercise on your own.
If not, pause the video right now.
It's so important to try tackling these things that you don't really know for sure how to solve them.
It's so important because when when you become a programmer, it's probably what you are going to face
most of your career, things that you're not sure how to solve.
And this is a good start to begin with.
So now let's think about the answer together and see if it's really possible to create such a program
with the tools we were even introduced with so far.
And first of all, what I want us to do is to write some common template for our program.
So like previously, we defined a and numb a numb.
We defined a numb.
And here we are going to define two variables, num and POW.
And these Val is going to represent the power.
And of course, Nami is going to represent the number.
And now we are going to print some message to the user, read the value, read the NUM.
And now we are going to also read of the power.
The user is going to specify which we didn't do this type of thing.
Previously, the user was going to specify the power that he wants.
So we are going to read this value and put it inside the power variable.
So up to this point, I guess we all did pretty much the same thing we've just received from the user.
The number and it's power.
And just to let me know, guys, there is actually no building power.
Operator in C, for example, we know that we can use an additional operator, which is a plus sign
or maybe multiplication operator, which is a multiplication sign.
But there is no such standard mark for a powering C.
And please don't tell me.
Just use the math, that H thing and so on.
Guys who didn't learn the necessary material for this use that she had.
So please don't try to get ahead of time.
We will get to these topics in the future.
Don't worry.
For now, just use the tools we've learned so far in the course up to this point and try to solve these
things just with these tools.
OK.
So we know that none in any power is simply numb, multiplied by numb, multiplied by numb.
A total of power, minus one multiplications.
For example, now, I mean, the power of three is simply numb, multiplied by numb, multiplied by
now.
All right.
So once again, if we have numb in any power, then the result is numb, multiplied by numb power minus
one times.
Right.
We repeat the multiplication process.
Power minus one times.
All right.
So now we also know a little bit about math, and that shouldn't be the point where you've got stuck
because, I mean, can't you know in advance how many times should you multiply a number that you received
from the user?
You can do that, right?
You dump all of these much in advance.
You could simply write down like we've used right here.
You can multiply num multiplied by num, which is a num in the power of two or nomine the power three.
But that wouldn't be the right answer because if the user specifies a power or four, what should you
print.
Should you print knowing the power of touring the power of three.
That just doesn't make any sense.
So basically what we want to have is something like this and we want to use a print F of function and
print functionality that will be seen like this guy here.
Right now I'm in the power of power equals two now, multiplied by now, multiplied by NOM and so on.
PO minus one times.
Like we can see the formula here under the right.
Top.
And that's not something that we can do with the tools we've learned so far.
And this is exactly the point where we should introduce a new body called Loop's.
You see, guys, when we want to calculate a NUM in some power, what we are actually doing is repeating
some process of multiplication over and over again.
Right.
We are simply multiplying.
Now, my name is certain amount of times and whenever there is a repetitive process or a bunch of commands
which are being run over and over again, we should start thinking of loops as something that can help
us with solving this task.
So let us see the structure of loops and a couple of basic examples with the using loops in C.
And then we will come back to the power as example to add the pole functionality to our calculator.
All right.
So 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.