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 the format specifier for printing a pointer value?
What is abstract data structure in c?
Can i use “int” data type to store the value 32768? Why?
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.
a program that can input number of records and can view it again the record
Is that possible to add pointers to each other?
What is union in c?
Implement bit Array in C.
What are the types of unary operators?
What are header files and what are its uses in C programming?
Explain why can’t constant values be used to define an array’s initial size?
What is omp_num_threads?
What is the difference between int main and void main?
What is the difference between c and python?
What are the two forms of #include directive?