Welcome back to this tutorial.
So let's just get into it right away.
Just go ahead and switch these around.
So it's "less than" and then "equal to"
Sorry, I think I committed error there in the last tutorial.
Doesn't really matter. Just switch it around.
We still didn't run the code
and I have also added, prior to the beginning of this tutorial
"i" at the end of each one of these lines, just for the sake of demonstration purposes
so that you can see that "i", with each pass, will increase.
So let us conduct a first pass and see what happens
Okay, let's go ahead and compile
It says nothing to do because I haven't really haven't done anything.
11
It should be "A is greater than B" now.
A is greater than B, and i is zero.
So you can see that it's here, it's getting printed out, and it's zero.
so let's go ahead and continue to loop at state being in four and then type in
10 should bibi is rated M for ya
is less than be there so rude but these pages then it says here one so it has
increased by one and if I just keep on doing this to allow its 3 end once it
reaches 3 it says game over it can't go it can't go any further than that
because we just stated it can to go the loop cannot repeat itself one more time
because then it would be greater because then it would be greater than three and
it becomes greater than three this evaluates to false and this entire loop
gets terminated as it exits the loop and it's just rinse out game over
anyway that would be D while loop which you can use we also have a for loop so
let's go ahead and actually lets you use most of the code here and we need to
delete the last curly bracket and we're not gonna have the eye plus plus here
let's go ahead and delete that as well and we won't need the creation site here
I know what's going to deport AP in for open open parenthesis in equal now you
can do this without any problems
equals 0 semicolon is less than three
bottom ok here we go this will do exactly the same thing even the compiler
it's pretty much the same thing there was no different machine doesn't
differentiate I don't think it differentiates at all there might be
some slight differences between for a while but I do believe that many that I
have read many statements that they're pretty much the same as far as the
machine is concerned for a while so we're just using them to create
repetitive action something or continuous action of something anyway
let's go ahead and go ahead and run this see what happens
changes
so it does run again the eye is it rating as you can see and it reaches to
because we didn't state that it is equal to not within the stated that's equal we
just said ok I needs to be less than three and that is quite literally all
while I'm here on the subject
go ahead and introduce one more value so another value would be float variable
type sorry has introduced senator variable day load that would be in BC D
E
that be equal to zero point something so if you want you can put it in like this
then them win three or zero points so this is just a great zero point that
sounded terrible type anyway if you are uncertain as to which variable to use if
numbers are concerned just use double you can't actually in terms of numbers
you can't actually go wrong with double next up what I would like to do is just
go ahead and show you a little bit of the mathematical operations that happen
so let's delete this ok so let's go ahead and demonstrate an idea
exxon so we have three variable types so let's let's play around and just give
them five and this is going to be so if I don't see out if I did I B B equals
sorry be easy to do and a is equal to five and if I do this I see a device a
divided by the way I would like you to take a wild guess what the result will
be remembered into juice can only be whole numbers and we are dividing one
introduced by a mother integers so let's see what what the result will be let's
go ahead and press it
yes I did but we need we need this petition ok so is 5/8 be which is to the
result is to now as far as I know 5/2 is not equal to two but you know that's
just me
could be wrong and the whole mass of this world could be wrong as well let's
just assume that it's not let's assume that the mathematics of this world is
correct
5/2 is not to why why does this happen
well everything if you if you divide one in by a another in and if you get a
result something like then . blah blah blah the blah blah blah part will be
gone it will get truncated it will be like it didnt never existence of the
result is then put in something then will remain everything behind it will go
away I'm just using these numbers for reference sake it could be any other
number could be whatever whatever so this could be a result of integer
division and this whole number could be the result of integer division but you
will get this as a result and nothing else if you divide two in two years and
the other hand if we were to divide see by the so the lead this part I really
feel a crew rating it all the time and sure the student appreciated I do you
can see clearly what is going on it's double so see divided by Andy
template 3/16 2.34
or by the way when I see you don't appreciate it I mean like you just find
it boring today keep on retyping the same things over and over again that's
what I meant by that anyway you get a result 0.17% you will get the small
points here if you divide to double numbers also if you divide float numbers
as well so please be very careful with that was a lot of mistakes can happen
with this and you should be aware these things also by this point of time if you
haven't noticed each line of code has its own designated number indeed era
section in the console down below where the output is given if there are any
errors it will report the line where the area has
you will get you will get a report weird error has occurred occurred on which
line because it's fairly simple now but imagine if you had 300 400 lines that
the nightmare have reduced the font size but aside from that just take a look at
some other functionalities of the console which we're going to need to
follow tutorials safe I just a pin ups please
we use can I lead and I don't know these exclamation marks this is gonna run
forever basically this program will never stop until we terminated so how do
you deal with something like this right
summit oh well then they have to press it in time basically it's the let's
think of a better example of this is a really good way to crash a virtual
machine just overloaded like this I was think of a better example it's just type
something in that will not be harmful in any way caused the split maxi it will
just keep on printing the same word over and over again as fast as it possibly
can
which is not a good thing at all so let's go ahead and open sea in basically
this program will not consume CPU much the CPU or anything it will just wait
for user to improve something but it will continue to run anyway on the right
side you have a discriminate but so you can go ahead and click it but you can
also you also have the clear console so far this if I press STOP to see this
till the program is not running but this still remains and they could just the
console and it's gone forever
no more players a console is nice neat and clean basically the equivalent of a
clear command in Linux anyway I like to be you all farewell here
and we will see each other in a follow-up story will continue on the
basics they will be a few more of these tutorials and then we will actually jump
into the loggers source code don't worry if you don't catch everything don't
worry if you don't understand everything straight away it's ok no big deal just
ask in the discussions I'll be happy to help you out I'll be happy to explain
anything that remains unclear but I'm just saying don't be like I didn't
figure it out without all known not this is well just one word what am I gonna do
about it
addict not good so just asking to discussions and I will help you out no
worries there again you don't need to understand all of it immediately you
will as we progress through the course a lot of things will repeat themselves in
one form or another
anyway farewell and I'll see you in default story