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 |
What is the purpose of realloc()?
write a program in c language to print your bio-data on the screen by using functions.
int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above
Is malloc memset faster than calloc?
design and implement a data structure and performs the following operation with the help of file (included 1000 student marks in 5 sub. and %also) 1.how many students are fail in all 5 subjects (if >35) 2. delete all student data those are fail in all 5 subjects. 3. update the grace marks (5 no. if exam paper is 100 marks) 4. arrange the student data in ascending order basis of marks. 5.insert double of deleted students with marks in the list.
how to use virual function in real time example
What is scanf_s in c?
nic scientist exam
what is the other ways to find a logic to print whether a number is an even or odd wit out using % symbol??????? i know three different ways to print it. so i need any other different logic>>>>>
what is the output for this question: main() { int i=1; printf("%d%d%d",i,i++,++i); }
What is the code in while loop that returns the output of given code?
Hi can anyone tell what is a start up code?