How to find the given no is odd or even without checking of
any condition and loops. (Hint: Using array)
Answer Posted / amala v
import java.io.*;
public class even {
public static void main(String arg[])throws
IOException
{
String a[]={"even","odd"};
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
int n;
System.out.println("Enter no to find");
n=Integer.parseInt(br.readLine());
n=n%2;
System.out.println("given no is "+a[n]);
}
}
| Is This Answer Correct ? | 12 Yes | 3 No |
Post New Answer View All Answers
How macro execution is faster than function ?
Why dont c comments nest?
What does malloc () calloc () realloc () free () do?
What is the difference between functions abs() and fabs()?
What are the different types of endless loops?
I need a sort of an approximate strcmp routine?
List the difference between a 'copy constructor' and a 'assignment operator' in C?
What is c language and why we use it?
What does volatile do?
Which is better malloc or calloc?
What is selection sort in c?
What is calloc() function?
Is c easy to learn?
Is r written in c?
What are types of structure?