0
Why my code has 2 errors?
import java.util.*; public class Program { public static void CheckEven(int n){ if(n%2==0){ System.out.println("even"); }else{ System.out.println("not even given num.."); } } // int i=1,count=0; /*while(i<=n){ if(n%i==0){ count=count+1; i++; } if(count==2){ System.out.println("the given number is prime"); } else{ System.out.println("the given number is not prime number"); } }*/ public static void main(String[] args) { Scanner sc= new Scanner(System.in); n=sc.nextInt(); CheckEven(int n); }//please anybody tell me why my code have two errors }
1 Answer
+ 3
1. No type definition specified for variable <n>
Include data type when declaring <n>
int n = sc.nextInt();
2. On the contrary, no type specification used when calling a method
CheckEvent(n); // no type specific for method call argument(s)