Rabu, 20 April 2011

for and while

INPUT PROGRAM FOR

public class dua {
public static void main (String [] args){
for (int i=2; i<=10; i+=2)
System.out.print(i+" ")
}
}


outputnya :
2   4   6   8   10



INPUT PROGRAM WHILE

public class tiga {
    public static void main (String [] args){
        int n=3;
        while (n<20)
        { System.out.print(n+" "); n+=3; }
    }
}






Outputnya:

3 6 9 12 15 18

Tidak ada komentar:

Posting Komentar

chatme


ShoutMix chat widget