program to show given no. is odd or even in java
let,s discuss on even or odd number, if you enter odd number like 1, 3,5, 7........... then show the result is "given no. is odd", or you enter number like- 2,4,6,8........... then show result is "given no. is even".
below the mention program to show given no is odd or even. i suggest you that you can program in netbeans.
// program to show given no. is odd or even in java
package odd;
import java.util.Scanner;
public class Odd {
//param args the command line arguments
public static void
main(String[] args) {
//
TODO code application logic here
int i;
Scanner s = new Scanner(System.in);
System.out.println("enter n value:");
int n =s.nextInt();
if(n%2==0)
System.out.println("given no is even");
else
System.out.println("given no is odd");
}
}
0 comments: