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
What is the maximum length of an identifier?
how to write optimum code to divide a 50 digit number with a 25 digit number??
What is p in text message?
How are 16- and 32-bit numbers stored?
Is c still relevant?
Create a simple code fragment that will swap the values of two variables num1 and num2.
What is use of #include in c?
What is meant by int main ()?
how to execute a program using if else condition and the output should enter number and the number is odd only...
What does double pointer mean in c?
Is null always equal to 0(zero)?
What is difference between union All statement and Union?
What is 1d array in c?
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.
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