Computer Science, asked by mosisk700, 9 months ago

write java program to check a no. is odd or even​

Answers

Answered by vageeshgn2005
2

Answer:

i am not using scanner class

Explanation:

public class evenodd

{

public static void main(int num)//takes input by parameter

{

if(num%2 ==0)//prints even if the reaminder is 0

{

System.out.println("The number you entered is even");

}

else//prints odd if the remainder is not 0

{

System.out.println("The number you entered is odd");

}

}

Answered by sougatap57
1

Answer:

import java.util.*;

public class HelloWorld{

    public static void main(String []args){

      int a;

      Scanner sc=new Scanner(System.in);

      System.out.println("enter the number");

      a=sc.nextInt();

      if(a%2==0)

      {

      System.out.println("even:"+a);

      }

      else

      {

          System.out.println("odd:"+a);

      }

    }

}

Output

enter the number 5

odd:5

Similar questions