java:odd even

 

 Problem :

Q. Write a java program which check the number is even or not even

import java.util.*;

 private static final Scanner scanner = new Scanner(System.in);

  public static void main(String[] args) {

        int n = scanner.nextInt();

        scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

   if(n%2==0)

{

System.out.println("even");

}

else

System.out.println("odd");

}

}

output:




Post a Comment

Previous Post Next Post