write a java program to say whether the number is odd or even
Answers
import java.io.*;
class oddeven
{
public static void main(String args[]) {
DataInputStream ins= new DataInputStream(System.in); System.out.println("enter a no");
int n= Integer.parseInt(ins.readLine()); if ( n%2 ==0) { System.out.println(" even no");
}
else
{ System.out.println("odd no");
}
}
}
hope it helps
please mark as brainliest
u can also make this program by using scanner class...
Answer:
import java.util.*;
class odd and even
{
public static void main(string args[])
{
scanner sc = new scanner(system.in)
system.out.println("enter the value of n");
intn= sc.nextInt();
for(i=1;i<=n;i++)
{
if(i℅2==0)
{
system.out.println("even");
}
else
system.out.println("odd");
}
}
}