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

Output for following program using for loop only * * * * * * * * * * * * * * *

3 Answers  


What is C language Terminator?

15 Answers   TCS,


What are the __date__ and __time__ preprocessor commands?

0 Answers  


typedef struct { int i:8; char c:9; float f:20; }st_temp; int getdata(st_temp *stptr) { stptr->i = 99; return stptr->i; } main() { st_temp local; int i; local.c = 'v'; local.i = 9; local.f = 23.65; printf(" %d %c %f",local.i,local.c,local.f); i = getdata(&local); printf("\n %d",i); getch(); } why there there is an error during compiling the above program?

1 Answers  


a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list

0 Answers  






How do we make a global variable accessible across files? Explain the extern keyword?

0 Answers  


what are the uses of structure?

7 Answers   HCL,


What is a function in c?

0 Answers  


Write a C function to search a number in the given list of numbers. donot use printf and scanf

6 Answers   Honeywell, TCS,


What is bin sh c?

0 Answers  


while initialization of two dimensional arrays we can initialize like a[][2] but why not a[2][] is there any reason behind this?

4 Answers   Aptech,


what is a c-language.what is do.

4 Answers   HCL,


Categories