![]() |
C programming
write a C program , to find whether a number is ODD or EVEN without using Control structures , looping, arrays, functions , operators(namely relational, arithmetic , logical )??????????:):):):):):)
|
Re: C programming
OK, we can't use relational, arithmetic, logical operators, but we can use bit-wise and operator.
Code: CPP
|
Re: C programming
but control structures(if... else) also should not be used...... but ur logic is right....
try that!!!!!:) |
Re: C programming
We can always replace the if...else with the conditional operator <condition> ? <true case> : <false case> .
That way, the code becomes : Code: CPP
|
Re: C programming
hmmmm :)then i ll put my question , in this way... there is a way to print without this conditional operator also.... try:)
thank u |
Re: C programming
Then I would do it this way ;)
Code: CPP
|
Re: C programming
hmmmm :)..in my question i already said without using arrays toooo u should do it!!!!!!!:):)
|
Re: C programming
Code:
printf("1 for odd, 0 for even -> %d \n",A&1); |
Re: C programming
hmmmmmm this is the right answer..... :)
|
Re: C programming
Quote:
Quote:
|
| All times are GMT +5.5. The time now is 07:38. |