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
Write the syntax and purpose of a switch statement in C.
What is I ++ in c programming?
What is the use of bit field?
What is the difference between constant pointer and constant variable?
Can the size of an array be declared at runtime?
why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above
What is function what are the types of function?
Explain union. What are its advantages?
which type of aspect you want from the student.
how to find anagram without using string functions using only loops in c programming
What are the 4 types of programming language?
Explain what is the difference between far and near ?
writ a program to compare using strcmp VIVA and viva with its output.
Explain is it better to bitshift a value than to multiply by 2?
What is the use of a ‘ ’ character?