You are here:   HomeJava ProgrammingJava ArrayEnter a number from the keyboard and find out the Even-Odd pairs within that number.
by Dinesh Thakur Category: array

Here is the Java Example for Even-Odd pairs within that number:

import java.util.Scanner;

public class EvenOdd
                      public static void main(String a[])
                      Scanner sl=new Scanner(;
                      System.out.print("Enter Number: ");
                      int n = sl.nextInt();
                      int odd[]= new int[2];
                      int eve[] = new int[2];
                      int o =-1, e =-1;
                      StringBuffer sb = new StringBuffer();
                      for(int i=1;i<=n;i++)
                                          sb.append(eve[0] + " " + eve[1] +" ");
                                          e = -1;
                                      if(i%2 !=0)
                                            sb.append(odd[0]+ " " + odd[1]+",");
                                            o = -1;
                                  System.out.println(sb.delete(sb.length()-2, sb.length()));

Even-Odd pairs within that number

Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.

What's New and Popular

Popular Article