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
Did c have any year 2000 problems?
what are the 10 different models of writing an addition program in C language?
Which is an example of a structural homology?
Explain what are the different file extensions involved when programming in c?
How we can insert comments in a c program?
Explain how can I avoid the abort, retry, fail messages?
What is the use of void pointer and null pointer in c language?
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
Are the variables argc and argv are always local to main?
Which of these functions is safer to use : fgets(), gets()? Why?
If i have an array 0 to 99 i.e,(Size 100) I place the values 1 to 100 randomly like a[0]=29,a[1]=56 upto array[99].. the values are only between 1 to 100. getting the array values by using scanf.. If i entered one wrong element value line a[56]=108. how can i find it.. and also how to find the missing value in 1 to 100.. and i want to replace the missing values.. any one of them know please post your answer..
Why ca not I do something like this?
Explain how can I prevent another program from modifying part of a file that I am modifying?
How can I delete a file?
The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference