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 format specifier for printing a pointer value?

790


What is abstract data structure in c?

763


Can i use “int” data type to store the value 32768? Why?

967


Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.

845


a program that can input number of records and can view it again the record

1697


Is that possible to add pointers to each other?

1119


What is union in c?

847


Implement bit Array in C.

888


What are the types of unary operators?

888


What are header files and what are its uses in C programming?

858


Explain why can’t constant values be used to define an array’s initial size?

1103


What is omp_num_threads?

828


What is the difference between int main and void main?

793


What is the difference between c and python?

810


What are the two forms of #include directive?

868