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


Please Help Members By Posting Answers For Below Questions

Did c have any year 2000 problems?

646


what are the 10 different models of writing an addition program in C language?

1426


Which is an example of a structural homology?

767


Explain what are the different file extensions involved when programming in c?

625


How we can insert comments in a c program?

619






Explain how can I avoid the abort, retry, fail messages?

581


What is the use of void pointer and null pointer in c language?

614


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.

1507


Are the variables argc and argv are always local to main?

561


Which of these functions is safer to use : fgets(), gets()? Why?

625


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..

1577


Why ca not I do something like this?

581


Explain how can I prevent another program from modifying part of a file that I am modifying?

627


How can I delete a file?

620


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

664