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
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 |
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 |
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 |
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 |
what is the diffrenet bettwen HTTP and internet protocol
Explain continue keyword in c
Which control loop is recommended if you have to execute set of statements for fixed number of times?
How do you access command-line arguments?
What happens if a header file is included twice?
Explain what are header files and explain what are its uses in c programming?
given the piece of code int a[50]; int *pa; pa=a; to access the 6th element of the array which of the following is incorrect? a.*(a+5) b.a[5] c.pa[5] d.*(*pa + 5)
Is c# a good language?
What is a double c?
How do we swap or interchange any 2 numbers without using Temporary variable...Anybody can pls answer it.. Thanks in Advance
WHAT IS ABSTRACT DATA TYPE
What are the complete rules for header file searching?