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 is a macro different from a function?
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
How does struct work in c?
Write a program to produce the following output in c language? 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
what is the difference between structure and union?
Describe for loop and write a c program to sum the series X + x2/2! + x3 /3! + …….. up to fifteen terms.
how to print 2-D array using a single for loop?
2 Answers Mind Tree, TCS, Value Labs,
Why is C language being considered a middle level language?
what is output? main() { #define SQR(x) x++ * ++x int i = 3; printf(" %d %d ",SQR(i),i * SQR(i)); } a)9 27 b)35 60 c)20 60 d)15 175
Explain what is the concatenation operator?
What is dangling pointer in c?