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 difference between printf and scanf )?
What are the salient features of c languages?
"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
Write a program for finding factorial of a number.
What is time null in c?
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?
What is the difference between variable declaration and variable definition in c?
What is malloc return c?
What is dynamic variable in c?
Is c object oriented?
Is main an identifier in c?
Calculate 1*2*3*____*n using recursive function??
Why is c fast?
What is the difference between text and binary i/o?
What is header file definition?