Rabu, 11 Juni 2014

Pemrograman Java : Array Genap Ganjil

Diposting oleh Unknown di 03.14
public class arraygenapganjil{
public static void main(String[]args){

int ar[]={5,3,7,2,9,17,8,67,46,43,13,10,76,27,83};

for (int i=0;i<15;i++){
System.out.println("ar ["+i+"] ==> "+ar[i]);
}

System.out.println("\nElemen ar[] Bernilai Ganjil\n");
for (int i=0;i<15;i++){
if (ar[i] % 2 != 0){
System.out.println("ar ["+i+"] ==> "+ar[i]);}
}

System.out.println("\nElemen ar[] Bernilai Genap\n");

for (int i=0;i<15;i++){
if (ar[i] % 2 == 0){
System.out.println("ar ["+i+"] ==> "+ar[i]);}
}
}}

0 komentar:

 

Miss Galaxy Yoon Template by Ipietoon Blogger Template | Gift Idea