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 difference between typedef and #define?
Write a c pgm for leap year
11 Answers College School Exams Tests, IBM, TCS,
What is the main differences between C and Embedded C?
what is ur strangth & weekness
0 Answers Cognizant, LG Soft, NetEnrich,
What is the difference between mpi and openmp?
how can you print&scan anything using just one character? :) HINT: printf,scanf similer
what is the difference between strcpy() and memcpy() function?
code for replace tabs with equivalent number of blanks
what will be printed by this printf? printf("%c",printf("hi")["sharkselva"])); }
plz let me know how to become a telecom protocol tester. thank you.
Can you assign a different address to an array tag?
Write a program to display the no of bit difference between any 2 given numbers eg: Num1 will 12->1100 Num2 will 7->0111 the difference in bits are 2.