find a number whether it is even or odd without using any
control structures and relational operators?

Answers were Sorted based on User's Feedback



find a number whether it is even or odd without using any control structures and relational operato..

Answer / vinocit

#include<stdio.h>
int main()
{
int n=10000;
char *s[2]={"Even","Odd"};
printf("%s",s[n&1]);
return 0;
}

Is This Answer Correct ?    47 Yes 11 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / vinothkumar.r

But its much efficient just to find whether the last bit is
0 or 1

Is This Answer Correct ?    16 Yes 2 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / d.c.sathishkumar

#include<stdio.h>
main()
{
int n;
char *p[]={"Even","odd"};
Printf("Enter the number");
scanf("%d",&n);
n=n%2;
printf("The value is %s",a[n]);

}

Is This Answer Correct ?    17 Yes 8 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / shashi

#include<stdio.h>
main()
{
int n;
string s[2]={"Even","odd"};
Printf("Enter the number");
scanf("%d",&n);
n=n%2;
printf("The value is %s",s[n]);

}

Is This Answer Correct ?    11 Yes 2 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / vignesh1988i

the first answer is excellent .... superb..... this is what
i expected........ marvalous.......... congrats



thank u

Is This Answer Correct ?    10 Yes 5 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / vamsi

#include<stdio.h>
main()
{
int n;
string p[2]={"Even","odd"};
Printf("Enter the number");
scanf("%d",&n);
n=n%2;
printf("The value is %s",p[n]);

}

Is This Answer Correct ?    13 Yes 8 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / vignesh1988i

mind you sir == is an relational operator.................



thank u

Is This Answer Correct ?    5 Yes 1 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / abhradeep chatterjee

ya. the first answer has impressed me.

#include<stdio.h>
main()
{
int n;
string p[2]={"Even","odd"};
Printf("Enter the number");
scanf("%d",&n);
n=n%2;
printf("The value is %s",p[n]);

}

Is This Answer Correct ?    5 Yes 1 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / ruchi

#include<stdio.h>
#include<conio.h>
main()
{
int n;
char *p[]={"Even","odd"};
clrscr();
printf("Enter the number");
scanf("%d",&n);
n=n%2;
printf("The value is %s",p[n]);
getch();

}

Is This Answer Correct ?    5 Yes 1 No

find a number whether it is even or odd without using any control structures and relational operato..

Answer / ramesh

#include<stdio.h>
#include<conio.h>
main()
{
int n;
char *p[]={"Even","odd"};
clrscr();
printf("Enter the number");
scanf("%d",&n);
n=n%2;
printf("The value is %s",p[n]);
getch();

}

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More C Interview Questions

The differences between Windows XP and Windows Visa

8 Answers   HCL,


Which is not valid in C? 1) class aClass{public:int x;} 2) /* A comment */ 3) char x=12;

7 Answers  


Software Interview Questions

1 Answers   CAT,


Why cd or dvd are round why not square.

1 Answers  


how can be easily placed in TCS.

0 Answers   TCS,






what is the use of fflush() function?

2 Answers  


What is Heap?

3 Answers  


Under what circumstances does a name clash occur?

0 Answers   InterGraph,


How can I read/write structures from/to data files?

0 Answers  


Finding first/last occurrence of a character in a string without using strchr( ) /strrchr( ) function.

2 Answers  


How many types of errors are there in c language? Explain

0 Answers  


what is the hexidecimal number of 4100?

16 Answers   Google,


Categories