Computer Science, asked by aatmashrisanyal12, 1 year ago

write a program to check odd or even

Answers

Answered by lyric
1

import java.util.Scanner;


public class Num4


{


void main()


{


Scanner sc=new Scanner(System.in);


System.out.println("enter a no.");


int a =sc.nextInt();


if (a%2==0)


System.out.println("even");


else


System.out.println("odd");


}


}



nitish8089: error in your program edit it..
lyric: what error
nitish8089: if you don't write:
nitish8089: public static void main(String...args)
nitish8089: in place of..
nitish8089: void main() in java it gives an error..
nitish8089: may be you got..
Answered by nitish8089
0
import java.util.Scanner;

public class Program{

public static void main(String...args){

Scanner sc=new Scanner(System.in);

int a=sc.nextInt();

if(a%2==0){

System. out.println(a+" is an even number ");

}

else{

System. out.println(a+" is odd number ");

}

}

}
Similar questions