0% found this document useful (0 votes)
19 views13 pages

For Studes For Loop

For students

Uploaded by

conanripestone
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views13 pages

For Studes For Loop

For students

Uploaded by

conanripestone
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

For Loop SYNTAX

for (initialization; <test condition>;


<increment/operation>)
{
<statements/s>;
}
Example

for (int Ctr=1; Ctr>5; Ctr++)


{
System.out.println(Ctr);
}
Example

for (int Ctr=1; Ctr>5; Ctr++)


{
System.out.println(Ctr);
}
Runtime Error
Example

for (int Ctr=1; Ctr<5; Ctr--)


{
System.out.println(Ctr);
}
Example

for (int Ctr=1; Ctr<5; Ctr--)


{
System.out.println(Ctr);
}
Infinite Loop
Example1

for (int Ctr=1; Ctr<=5; Ctr++)


{
System.out.println(Ctr);
}
Example2

int Ctr;
for (Ctr=1; Ctr<=5; Ctr++)
{
System.out.println(Ctr);
}
Example3

for (int Ctr=1; Ctr<=5; Ctr++)


{
System.out.println(“Alingal”);
}
Example4

for (int Ctr=1; Ctr<=5; Ctr++)


{
System.out.print(Ctr + “ “);
}
Example5

for (int x=18; x>5; x-=5)


{
System.out.println(“x”);
}
Example6

for (int a1=3; a1<15; a1=a1*2)


{
System.out.print(a1);
}
Example7

for (int s=1; s<20; s=s+2)


{
System.out.println(s);
s=s*2;
}
Example8

for (int s=3; s<10; s=s+2)


{
s++;
System.out.print(s);
System.out.println(s*2); }

You might also like