Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Loops and Condition in java

Rating
-
Sold
-
Pages
1
Uploaded on
03-03-2023
Written in
2022/2023

Basics in loops and condition in java

Institution
Course

Content preview

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..

Written for

Institution
Course

Document information

Uploaded on
March 3, 2023
Number of pages
1
Written in
2022/2023
Type
Class notes
Professor(s)
Kunal kushwaha
Contains
All classes

Subjects

$15.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
ajeykarthikeyansundaram

Get to know the seller

Seller avatar
ajeykarthikeyansundaram Dr.Mahalingam college of engineering and technology
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions