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 a null pointer in c?
Explain c preprocessor?
what will be maximum number of comparisons when number of elements are given?
What are shell structures used for?
Why does the call char scanf work?
Why flag is used in c?
What is the symbol indicated the c-preprocessor?
How pointers are declared?
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers
Suggesting that there can be 62 seconds in a minute?
What are the 5 organizational structures?
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
c program for searching a student details among 10 student details
What is a floating point in c?
Why are algorithms important in c program?