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
What is volatile, register definition in C
What is typedf?
What is declaration and definition in c?
What is difference between %d and %i in c?
How can I find the modification date and time of a file?
What is a good data structure to use for storing lines of text?
What is the use of putchar function?
What are the disadvantages of c language?
Why header file is used in c?
What are the different types of pointers used in c language?
Explain how do you convert strings to numbers in c?
What does the c in ctime mean?
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.
Explain what is the difference between a free-standing and a hosted environment?
What is the function of this pointer?