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
write a program to print largest number of each row of a 2D array
Why #include is used in c language?
Explain bit masking in c?
What is the translation phases used in c language?
What are the features of c language?
Write a program to swap two numbers without using third variable?
What is identifiers in c with examples?
Why is c so popular?
What are qualifiers?
Why does this code crash?
How can I trap or ignore keyboard interrupts like control-c?
What is the use of gets and puts?
What is pointer to pointer in c?
the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above
How can I ensure that integer arithmetic doesnt overflow?