In Intellij id if you write for I it will create an iteration loop for yourself
automatically it created so I can say num starts from zero should be less than
equal to n Num plus plus and just start from 1. Also because I want to input print
numbers from 1 to n right. Let's say print number. while loops syntax is something
like this so you have the while loop condition over here. You write while then you
write the condition and then body that's it that is it let 's try to convert this
program of one to five numbers into a while loop so I can say while so basically
the initialization part I 'll just copy paste this for reference. a do. While loop
syntax is something like this do this thing while condition okay, let 's try it
out. I also explain the difference. Between okay, so do while and while the dowhile
loop and the while loop have one difference in it. the idea is it will execute at
least once and after that it will only execute when this while condition is true.
After that. in cases in which you definitely have to have one time the loop running
in that case, you can use a while loop..
Questions are important in order to understand how these things are working
internally. So let 's say we create a question like largest so you will be giving
three numbers. you have to figure out, which is the largest number from all these
three numbers, so one way we can do this. We can. assume that this is the. largest
number okay. We can take a maximum value. We can say maximum is equal to 10. then
we are going to check this with b is b greater than maximum that the current
maximum that i have is B.. There are many ways to solve one pro one one problem
Okay. There can be many ways if you do n't want to take the like the you know the
maximum one as uh as a or whatever you can say Initially something like let 's say
let me just let.. me just copy this thing okay. let 's try to run this if I give
three numbers 10, 30 27. It will print 30. Why because it is it is going to say
math. max. we are going to be inputting a number like a character not a number, so
we 'll look into it Later on like what is a carat and everything, but in case in
short. If you want to understand it 's not that complicated. This is a string care
at basically means give me the character at this index of the string string. You
can imagine it as a character array array..
If you want to add two conditions like both of these conditions need to be true,
you can use the and and and. and operator.. This is something we did not cover
before and so basically if you want it to print it will print if you say or you can
also add or or basically means either one of these should be true. If a is greater
than a the value like if it lies between the range of capital small a and small z.
I can say print uppercase. if a not equal to 35 it 's 10 hence it will print hello
world. the question is find the Nth fibonacci number so basically the zeroth first,
second, third, fourth, fifth sixth number seventh number is equal to 13. use a for
loop till you know till it runs till like seven or whatever and uh then basically.
We will just uh keep on adding and updating these two values. For example, the next
number will be a plus b, which is equal to one comma. A will then be replaced with
the B and a n will be 1..
automatically it created so I can say num starts from zero should be less than
equal to n Num plus plus and just start from 1. Also because I want to input print
numbers from 1 to n right. Let's say print number. while loops syntax is something
like this so you have the while loop condition over here. You write while then you
write the condition and then body that's it that is it let 's try to convert this
program of one to five numbers into a while loop so I can say while so basically
the initialization part I 'll just copy paste this for reference. a do. While loop
syntax is something like this do this thing while condition okay, let 's try it
out. I also explain the difference. Between okay, so do while and while the dowhile
loop and the while loop have one difference in it. the idea is it will execute at
least once and after that it will only execute when this while condition is true.
After that. in cases in which you definitely have to have one time the loop running
in that case, you can use a while loop..
Questions are important in order to understand how these things are working
internally. So let 's say we create a question like largest so you will be giving
three numbers. you have to figure out, which is the largest number from all these
three numbers, so one way we can do this. We can. assume that this is the. largest
number okay. We can take a maximum value. We can say maximum is equal to 10. then
we are going to check this with b is b greater than maximum that the current
maximum that i have is B.. There are many ways to solve one pro one one problem
Okay. There can be many ways if you do n't want to take the like the you know the
maximum one as uh as a or whatever you can say Initially something like let 's say
let me just let.. me just copy this thing okay. let 's try to run this if I give
three numbers 10, 30 27. It will print 30. Why because it is it is going to say
math. max. we are going to be inputting a number like a character not a number, so
we 'll look into it Later on like what is a carat and everything, but in case in
short. If you want to understand it 's not that complicated. This is a string care
at basically means give me the character at this index of the string string. You
can imagine it as a character array array..
If you want to add two conditions like both of these conditions need to be true,
you can use the and and and. and operator.. This is something we did not cover
before and so basically if you want it to print it will print if you say or you can
also add or or basically means either one of these should be true. If a is greater
than a the value like if it lies between the range of capital small a and small z.
I can say print uppercase. if a not equal to 35 it 's 10 hence it will print hello
world. the question is find the Nth fibonacci number so basically the zeroth first,
second, third, fourth, fifth sixth number seventh number is equal to 13. use a for
loop till you know till it runs till like seven or whatever and uh then basically.
We will just uh keep on adding and updating these two values. For example, the next
number will be a plus b, which is equal to one comma. A will then be replaced with
the B and a n will be 1..