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

How can a program be made to print the name of a source file where an error occurs?

0 Answers  


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)

1 Answers  


What is output redirection?

0 Answers  


What is signed and unsigned?

0 Answers  


Prove or disprove P!=NP.

5 Answers   Microsoft,






Explain the difference between ++u and u++?

0 Answers  


What is the maximum no. of arguments that can be given in a command line in C.?

0 Answers   HCL,


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

4 Answers   Aspire,


#include<stdio.h> int main(){ int a[]={1,2,3,5,1}; int *ptr=a+4; int y=ptr-a; printf("%d",y); }

3 Answers   Zoho,


Is flag a keyword in c?

0 Answers  


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 + + + + + + + + + + + + + + + + +

1 Answers  


Categories