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
Explain what header files do I need in order to define the standard library functions I use?
int far *near * p; means
Can we access the array using a pointer in c language?
What is a constant and types of constants in c?
How to declare pointer variables?
Do pointers need to be initialized?
write a program fibonacci series and palindrome program in c
Write a program with dynamically allocation of variable.
Explain how can I remove the trailing spaces from a string?
Which is best book for data structures in c?
Explain 'far' and 'near' pointers in c.
What are the restrictions of a modulus operator?
Explain c preprocessor?
Explain the difference between call by value and call by reference in c language?
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.