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

What is volatile, register definition in C

684


What is typedf?

664


What is declaration and definition in c?

521


What is difference between %d and %i in c?

689


How can I find the modification date and time of a file?

598






What is a good data structure to use for storing lines of text?

590


What is the use of putchar function?

646


What are the disadvantages of c language?

614


Why header file is used in c?

573


What are the different types of pointers used in c language?

610


Explain how do you convert strings to numbers in c?

591


What does the c in ctime mean?

561


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.

1475


Explain what is the difference between a free-standing and a hosted environment?

632


What is the function of this pointer?

668