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 |
#define MAX 3 main() { printf("MAX = %d ",MAX ); #undef MAX #ifdef MAX printf("Vector Institute”); #endif }
How many bytes is a struct in c?
Write a program to check prime number in c programming?
When can you use a pointer with a function?
Is c compiled or interpreted?
how to find out the union of two character arrays?
to get a line of text and count the number of vowels in it
What are different types of operators?
Why static is used in c?
Difference between malloc() and calloc() function?
WAP TO ACCEPT STRING AND COUNT A COMES N TIMES B COMES N TIMES C COMES N TIMES D COMES N TIMES AND SO ON......... AT LAST UNTIL Z COMES N TIMES...............
Why we write conio h in c?