0% found this document useful (0 votes)
17 views5 pages

Java For Loop Output Examples

The document contains a series of code snippets demonstrating various for loop behaviors in Java. Each snippet is followed by its corresponding output, showcasing different iterations, increments, and print statements. Some loops result in infinite outputs or no output at all due to their conditions.

Uploaded by

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

Java For Loop Output Examples

The document contains a series of code snippets demonstrating various for loop behaviors in Java. Each snippet is followed by its corresponding output, showcasing different iterations, increments, and print statements. Some loops result in infinite outputs or no output at all due to their conditions.

Uploaded by

abhijaysingh86
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Output Questions

1)int i ;

for( i=1 ; i<=5 ; i++)

[Link](i +”;”);

output

1;2;3;4;5;

2)int i ;

for( i=1 ; i<=5 ; i+=2)

[Link](i +”;”);

output

1;3;5;

3)int i ;

for( i=1 ; i<=5 ; i++)

[Link](++i +”;”);

output

2;4;6;
4)int i ;

for( i=1 ; i<=5 ; i++)

[Link](i ++ +”;”);

output

1;3;5;

5)int i ;

for( i=1 ; i<=5 ; )

[Link](i +”;”)

output

1;1;1;1;…………infinite loop

6)int i ;

for( i=1 ; i<=5 ; i++)

[Link](i );

output

3
4

7)int i ;

for( i=1 ; i<=5 ; i++)

[Link](i +”;”);

[Link](i +”;”);

output

1;2;3;4;5;6;

8)int i ;

for( i=1 ; i<=5 ; i++)

[Link](i +”;”);

[Link](i +”;”);

[Link](i+5 );

output

1;2;3;4;5;6;

11
9)int i ;

for( i=1 ; i<=5 ; i++)

[Link](i +”;”);

[Link](i +”;”);

[Link](+i+5 );

Output

1;2;3;4;5;6;

65

10)int i ;

for( i=1 ; i<=5 ; i++)

[Link](i +”;”);

[Link](i +”;”);

[Link](+(i+5) );

Output

1;2;3;4;5;6;

11
11)int i ;

for( i=1 ; i>5 ; i++)

[Link](i +”;”);

[Link](i +”;”);

[Link](+i+5 );

Output

1;

15

12)int i ;

for( i=1 ; i>5 ; i++)

[Link](i +”;”);

No output

13)int i ;

for( i=1 ; ; i++)

[Link](i +”;”);

1;2;3;…………….infinite time

You might also like