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 would be an example of a structure analogous to structure c?
Why c is a procedural language?
Explain what are run-time errors?
What is FIFO?
What are pragmas and what are they good for?
What is a structure member in c?
c program for searching a student details among 10 student details
You have given 2 array. You need to find whether they will
create the same BST or not.
For example:
Array1:10 5 20 15 30
Array2:10 20 15 30 5
Result: True
Array1:10 5 20 15 30
Array2:10 15 20 30 5
Result: False
One Approach is Pretty Clear by creating BST O(nlogn) then
checking two tree for identical O(N) overall O(nlogn) ..we
need there exist O(N) Time & O(1) Space also without extra
space .Algorithm ??
DevoCoder
guest
Posted 3 months ago #
#define true 1
#define false 0
int check(int a1[],int a2[],int n1,int n2)
{
int i;
//n1 size of array a1[] and n2 size of a2[]
if(n1!=n2) return false;
//n1 and n2 must be same
for(i=0;i
What is the heap in c?
If the size of int data type is two bytes, what is the range of signed int data type?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
Why should I prototype a function?
What is the use of bit field?
In a header file whether functions are declared or defined?
which type of aspect you want from the student.