To find whether a number is even or odd without using any
conditional operator??

Answer Posted / amala v

import java.io.*;

public class even {
public static void main(String arg[])throws IOException
{
String a[]={"even","odd"};
int p;
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Enter a number to find:");
int n=Integer.parseInt(br.readLine());
p=n%2;
System.out.println("The Number is :"+a[p]);


}
}

Is This Answer Correct ?    24 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Describe newline escape sequence with a sample program?

899


What is putchar() function?

863


Hai what is the different types of versions and their differences

1743


What is difference between union All statement and Union?

898


Write a program to print fibonacci series without using recursion?

857


In a byte, what is the maximum decimal number that you can accommodate?

906


List some basic data types in c?

783


What is the purpose of 'register' keyword in c language?

830


How do I use void main?

864


What is register variable in c language?

850


An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode

858


How many levels of indirection in pointers can you have in a single declaration?

853


Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

852


Is printf a keyword?

989


How can I change their mode to binary?

908