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 |
How can a program be made to print the name of a source file where an error occurs?
Display names and numbers of employees who have 5 years or more experience and salary less than Rs.15000 using array of structures (name, number, experience and salary)
What is output redirection?
What is signed and unsigned?
Prove or disprove P!=NP.
Explain the difference between ++u and u++?
What is the maximum no. of arguments that can be given in a command line in C.?
I need to take a sentence from input and sort the words alphabetically using the C programming language. Note: This is C not C++. qsort and strtok not allowed
#include<stdio.h> int main(){ int a[]={1,2,3,5,1}; int *ptr=a+4; int y=ptr-a; printf("%d",y); }
Is flag a keyword in c?
Difference between macros and inline functions? Can a function be forced as inline?
0 Answers HAL, Honeywell, Zomato,
Print the foll in C...eg when n=5 the o/p must b + + + + + + + + + + + + + + + + +