import java.io.*;
class NumOfDigits{
public static void main(String[]args)throws IOException{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int num = Integer.parseInt(reader.readLine());
int count=0;
if(num>0 && num<1000)
while(num!=0){
num /= 10;
count++;
}
if (num%2==0)
System.out.println("Even number");
else if(num%2==1){
System.out.println("Odd number");
}
System.out.println("Number of digit in the given number: "+ count);
}
}
See my odd num condition line 22 what is wrong in this
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Nouser
24 January 2021, 14:23
At the time you check num %2 == 0, num is zero and you always will get an even output (cause you're doing that check outside the loop).
0