11:09 pm - Sunday July 15, 2018

Java program for Even Odd Number

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/**

*@author :CandidJava.com

*@descriptions : To write the program using to find out even numbers.

*/

class FindEvenorOdd

{

public static void main(String args[]) {

//  creating new array which has  10 elements

int [] numbers = new int[] {1,7,8,4,5,3,7,8,9,10};

//numbers.length  is used  to find the length of the given array

for(int i=0;i<=numbers.length;i++){

//Check  given number is whether odd number or even number using  modulus  operator(%)

if(numbers[i]%2==0)

//print if  (number[i]%2==0 ) the given number is even number . otherwise given number is odd

System.out.println(numbers[i]+" given number is even");

else

System.out.println(numbers[i] +" given number is odd");

}

}

}


Output:

E:\ Candidjava\Code >javac FindEvenorOdd.java

E:\ Candidjava\Code >java FindEvenorOdd

1 given number is odd

7 given number is odd

8 given number is even

4 given number is even

5 given number is odd

3 given number is odd

7 given number is odd

8 given number is even

9 given number is odd

10 given number is even

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply