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 are the advantage of c language?
Explain pointers in c programming?
What is meant by recursion?
Explain function?
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
write a program to generate address labels using structures?
Why c is faster than c++?
Define recursion in c.
What is break statement?
How does #define work?
What is function pointer c?
Explain the meaning of keyword 'extern' in a function declaration.
What is the equivalent code of the following statement in WHILE LOOP format?
What are the string functions? List some string functions available in c.
Where can I get an ansi-compatible lint?