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 |
how can write all 1to 100 prime numbers using for loop,if and break ?
Is multithreading possible in c?
Write a C program that defines a 2-dimentional integer array called A [50][50]. Then the elements of this array should randomly be initialized either to 1 or 0. The program should then print out all the elements in the diagonal (i.e. a[0][0], a[1][1],a[2][2], a[3][3], ……..a[49][49]). Finally, print out how many zeros and ones in the diagonal.
What is the general form of #line preprocessor?
pierrot's divisor program using c or c++ code
Why cann't whole array can be passed to function as value.
write a program to find the number of even integers and odd integers in a given array in c language
13 Answers IAI Cameroun, NIIT, Olive Tech, QIS,
What are the header files used in c language?
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
what is the difference between procedure oriented and object oriented progaming language
In a byte, what is the maximum decimal number that you can accommodate?
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above