let number = 15;
if(number % 2 ==0){
console.log( number + 'is Even Number');
}
else{
console.log(number " is Odd Number");
}
a = int(input("Enter the number: "))
if (a % 2) == 0:
print("{0} is even".format(a))
else:
print(" {0} is odd ".format(a))
public class EvenOdd{
public static void evenOddValue(int value) {
if(value % 2 == 0){
System.out.println("The given value is even: " + value);
}
else{
System.out.println("The given value is odd: " + value);
}
}
public static void main(String [] args) {
int num = 25;
EvenOdd obj = new EvenOdd();
obj.evenOddValue(num);
}
}
Numbers -- odd & even
Write a method which can identifies given number is even or odd
EX:
identify(5) -> "Odd"
identify(6) -> "Even"
Solution :
public static String identifyOddEven( int n ) {
return n%2==0 ? "Even" : "odd" ;
}