Friday, February 13, 2015

For Loop

A simple For loop example which illustrates 6 multiples and this can be extended for any multiples.


package Example1;

public class ForLoopExample {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  System.out.println("Display's 6 multiples");
  for(int i=6;i<=60;i+=6){
   if(i%6==0){
    System.out.println(i);
   }
  }
 }

}


output:
Display's 6 multiples
6
12
18
24
30
36
42
48
54
60

>>>do While
------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment