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 c.
How are variables declared in c?
What are logical errors and how does it differ from syntax errors?
Explain what is a 'locale'?
Write a code to generate divisors of an integer?
void main() { char c; while(c=getchar()!='\n') printf("%d",c); } o/p=11 why?
Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer
Heyyy All, Just a challenge . A C program with if Else if(){ /// insert sumthing print ("in if") // insert sumting } else { ///// insert sumthing print ("in else"); //// insert sumthing } can anyone modify it so that program prints. if and else both
What are near, far and huge pointers?
0 Answers Hexaware, Thomson Reuters, Virtusa,
hello everybody can we change a the adress of a variabl i mean can i put for exemple for a int *p: &p=6 ?????????
write c program to display output 10(10+20)+(10+20+30)+ ... n term
0 Answers Hindustan Gum Chemicals,
What is the need of structure in c?