How to find the given no is odd or even without checking of
any condition and loops. (Hint: Using array)

Answers were Sorted based on User's Feedback



How to find the given no is odd or even without checking of any condition and loops. (Hint: Using ..

Answer / 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

How to find the given no is odd or even without checking of any condition and loops. (Hint: Using ..

Answer / vaishu

void main()
{
int n;
char s[]={"even","odd"};
printf("Enter the no.:");
scanf("%d",&n);
n=n%2;
printf("th no. is %s",s[n]);
getch();
}

Is This Answer Correct ?    12 Yes 7 No

How to find the given no is odd or even without checking of any condition and loops. (Hint: Using ..

Answer / ligory antony

void main()
{
int n;
char *s[4]={"even","odd"};
printf("Enter the no.:");
scanf("%d",&n);
n=n%2;
printf("th no. is %s",s[n]);
getch();
}

Is This Answer Correct ?    6 Yes 4 No

How to find the given no is odd or even without checking of any condition and loops. (Hint: Using ..

Answer / anandi

void main()
{
int n;
char s[20][20]={"even","odd"};
printf("Enter the no.:");
scanf("%d",&n);
n=n%2;
printf("th no. is %s",s[n]);
getch();
}

Is This Answer Correct ?    3 Yes 3 No

Post New Answer

More C Interview Questions

How can I rethow can I return a sequence of random numbers which dont repeat at all?

0 Answers  


What is the use of header files?

0 Answers  


Write a program in C to convert date displayed in gregorian to julian date

0 Answers   HCL, Wipro,


please give me a VIRTUSA sample palcement papers.... you will only send TECHNICAL SECTION..... that is help for me Advance Thanks........................

0 Answers  


What is define c?

0 Answers  






Differentiate between new and malloc(), delete and free() ?

0 Answers   iNautix,


Explain what happens if you free a pointer twice?

0 Answers  


What is abstract data structure in c?

0 Answers  


What is .obj file in c?

0 Answers  


What are terms in math?

0 Answers  


what is Array?

3 Answers  


What is the process to create increment and decrement stamen in c?

0 Answers  


Categories