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

What is the maximum length of an identifier?

877


how to write optimum code to divide a 50 digit number with a 25 digit number??

2969


What is p in text message?

728


How are 16- and 32-bit numbers stored?

958


Is c still relevant?

839


Create a simple code fragment that will swap the values of two variables num1 and num2.

1027


What is use of #include in c?

817


What is meant by int main ()?

936


how to execute a program using if else condition and the output should enter number and the number is odd only...

1921


What does double pointer mean in c?

772


Is null always equal to 0(zero)?

784


What is difference between union All statement and Union?

863


What is 1d array in c?

840


Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.

1832


Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250

1728