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 typedef?
What is the best way to comment out a section of code that contains comments?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
How can I do peek and poke in c?
Is c object oriented?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
What are data types in c language?
Explain is it better to bitshift a value than to multiply by 2?
C language questions for civil engineering
How can you allocate arrays or structures bigger than 64K?
What are the rules for the identifier?
What is the right way to use errno?
Why is c fast?
What is page thrashing?
swap 2 numbers without using third variable?