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

Explain how many levels deep can include files be nested?

0 Answers  


Differentiate between static and dynamic modeling.

0 Answers   Wipro,


What is a header file?

0 Answers  


what will be the output of this program main() { int i=1; while (i<=10); { i++; } }

11 Answers  


Write programs for String Reversal & Palindrome check

0 Answers   TISL,


extern static int i func() { i =10; i++; printf("%d \n",i); } main() { i =20; printf("%d \n",i); func(); printf("%d \n",i); }

2 Answers  


Derive the complexity expression for AVL tree?

1 Answers  


How can I avoid the abort, retry, fail messages?

0 Answers  


What are local static variables?

0 Answers  


What is #include stdio h and #include conio h?

0 Answers  


What are the different types of C instructions?

0 Answers   InterGraph,


Why static variable is used in c?

0 Answers  


Categories