Loops in java
<a href=" https://www.teeztareen.com/2019/07/loops-in-javajava-programming.html ">loops in java
programming</a><br />
Loops in java||A type of control structure repeats a statement a set of the statement is
known as a looping structure. It is also known as iterative or repetitive structure.in sequential
structure, all statement is executed. At once .on the other hand conditional structure executed or
skip on the base of a given condition.in some situation, it is required to repeat a statement
number of statements for a specified number of times. Looping structure is used for this
purpose .thiere different type of loop is available in c++.Java provides the powerfull construct
called a loop that controls how many times an operation or sequence of operation is performed in
succession .using a loop statement you simply tell the computer to print a string a hundred
time without having a code the print statement a hundred times as follows.
Int count =0;
While(count<100)
{
System.out.printin(“welcome to java”);
Count++;
}
The variable count its is initial value is zero.the loop check the weather (count<100)is true .it
execute loop body to print the message “welcome to java !”increment count by .it repeate and
execute the loop body until (count<100) becomes false .when count less then 100(count<100) is
false (when count reaches hundred 100) the loop terminates and the next statement after the loop
statement is executed .
Loop is used basically for two purposes.
1. To execute a statement or number of statements for a specified number of times. For example,
a user may display your name 10 time .
2. To use a sequence of values . for example, a user may display a set of natural numbers from 1
to ten.
There are three types of loop available in c++ .these are follow .
1.While loop 2.do while loop 3.for loop
Counter_ controlled loops
This loop depends on the value of a variable known as the counter variable.
The value of counter variables is incremented or decremented each time the body of the loop is
executed .this loop is terminated when the value of the counter variable reaches a particular
value. The number of iterations of a counter controlled loop is known in advance .the iteration of
the loop depends on the following.
1.initial value of the counter variable.
2.Terminating condition
3.Increment or decrement value
Sentinel controlled loops
This type of loop depends on a special value known as sentinel value .the loop is
terminated when the sentinel value is encountered the .these type of loops are also
known as conditional loop. For example, a loop may execute while the value of
variables is not -1 .here the -1 is sentinel value that is used to terminate the loop. The
number of iteration of the sentential_controlled loop is unknown .it depends on the
input from the user .suppose the essential value to terminate a loop is -1. if the user
enters s -1 in the first iteration, the loop will be executed only once .but if the user
enters -1 after entering many other values, the number of iterations will vary
accordingly. an initial value is commonly used with a will and do-while loops.
<a href="https://www.teeztareen.com/2019/06/nested-if-statement-in-java-
programming.html">Nested if else statement</a><br />
<a href="https://www.teeztareen.com/2019/06/if-else-statement-in-java.html">If else statement in
java</a><br />
<a href="https://www.teeztareen.com/2019/06/if-statement-in-java-programing.html">If statement in
java</a><br />
<a href="https://www.teeztareen.com/2019/06/simple-program-in-java-for-beginners.html">A simple
program in java for begnners</a><br />
<a href="https://www.teeztareen.com/2019/06/systemoutprintin-in-java-
program.html">System.out.printin() in java</a><br />
<a href="https://www.teeztareen.com/2019/06/blog-post_18.html">Public static void main ( String
args[] ) in java program.</a><br />
<a href="https://www.teeztareen.com/2019/06/the-basic-structure-of-java-program.html">The basic
structure of the java program.</a><br />
<a href="https://www.teeztareen.com/2019/06/blog-post_16.html">Data types in java with
examples(write and video tutorial</a><br />
<a href="https://www.teeztareen.com/2019/06/what-is-jvmjava-virtual-machine.html">what is
JVM(java virtual machine)</a>
<a href="https://www.teeztareen.com/2019/06/java-8-features.html">java 8 features</a><br />
<a href="https://www.teeztareen.com/2019/06/what-is-javawhy-use-java.html">What is Java
programming and java history</a>