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 / ramya

A number anded with the lower number that is n & (n - 1) =
0 then it is even if it is anything else it is odd

odd_even (int n)

{
if (!(n & (n -1))
number is odd
else
number is even

}

Is This Answer Correct ?    9 Yes 29 No

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

Answer / guest

#include<stdio.h>
#include<conio.h>
void main()
{
int x;
if(x%2==0)
printf("even");
else
printf("odd");
getch();
}

Is This Answer Correct ?    4 Yes 25 No

Post New Answer

More C Interview Questions

Explain the use of function toupper() with and example code?

0 Answers  


Dear Sir, we are required the bubble sorting programs Regs Prem

1 Answers  


WRITE A PROGRAM TO FIND A REVERSE OF TWO NO

7 Answers  


Is main is a keyword in c?

0 Answers  


Describe dynamic data structure in c programming language?

0 Answers  


How can I access a memory located at certain address?

2 Answers   CSC,


What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25

0 Answers  


Explain why C language is procedural?

0 Answers   GE,


Why pointers are used?

0 Answers  


In which layer of the network datastructure format change is done

0 Answers   Honeywell,


Do you know pointer in c?

0 Answers  


What are the advantages of Macro over function?

1 Answers  


Categories