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

what is the diffrenet bettwen HTTP and internet protocol

0 Answers  


Explain continue keyword in c

0 Answers  


Which control loop is recommended if you have to execute set of statements for fixed number of times?

0 Answers  


How do you access command-line arguments?

1 Answers  


What happens if a header file is included twice?

0 Answers  






Explain what are header files and explain what are its uses in c programming?

0 Answers  


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)

6 Answers   amu, TCS,


Is c# a good language?

0 Answers  


What is a double c?

0 Answers  


How do we swap or interchange any 2 numbers without using Temporary variable...Anybody can pls answer it.. Thanks in Advance

8 Answers  


WHAT IS ABSTRACT DATA TYPE

4 Answers   Wipro,


What are the complete rules for header file searching?

0 Answers  


Categories