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
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 |
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 |
write a program fibonacci series and palindrome program in c
0 Answers Aditi Placement Service,
Differentiate between new and malloc(), delete and free() ?
What is function and its example?
Explain output of printf("Hello World"-'A'+'B'); ?
What is clrscr in c?
Explain a pre-processor and its advantages.
In header files whether functions are declared or defined?
How do I create a directory? How do I remove a directory (and its contents)?
difference between spiral and waterfall model
How many levels deep can include files be nested?
write a c program to find the sum of five entered numbers using an array named number
what is diff b/w huge & far & near pointer??