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 are the advantage of c language?

556


Explain pointers in c programming?

640


What is meant by recursion?

636


Explain function?

667


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.

2459






write a program to generate address labels using structures?

4013


Why c is faster than c++?

637


Define recursion in c.

704


What is break statement?

637


How does #define work?

654


What is function pointer c?

591


Explain the meaning of keyword 'extern' in a function declaration.

733


What is the equivalent code of the following statement in WHILE LOOP format?

774


What are the string functions? List some string functions available in c.

611


Where can I get an ansi-compatible lint?

646