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 is the difference between printf and scanf )?

585


What are the salient features of c languages?

619


"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks

652


Write a program for finding factorial of a number.

629


What is time null in c?

579






If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?

773


What is the difference between variable declaration and variable definition in c?

558


What is malloc return c?

594


What is dynamic variable in c?

559


Is c object oriented?

534


Is main an identifier in c?

593


Calculate 1*2*3*____*n using recursive function??

1509


Why is c fast?

600


What is the difference between text and binary i/o?

586


What is header file definition?

563