




|
Banned
|
|
| 23Sep2009,08:55 | #1 |
|
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 )??????????
![]() ![]() ![]() ![]() ![]()
|
|
~ Б0ЯИ Τ0 С0δЭ ~
|
![]() |
| 23Sep2009,19:05 | #2 |
|
OK, we can't use relational, arithmetic, logical operators, but we can use bit-wise and operator.
Code: CPP
|
|
Banned
|
|
| 25Sep2009,02:51 | #3 |
|
but control structures(if... else) also should not be used...... but ur logic is right....
try that!!!!!
|
|
~ Б0ЯИ Τ0 С0δЭ ~
|
![]() |
| 25Sep2009,16:23 | #4 |
|
We can always replace the if...else with the conditional operator <condition> ? <true case> : <false case> .
That way, the code becomes : Code: CPP
|
|
Banned
|
|
| 25Sep2009,18:17 | #5 |
|
hmmmm
then i ll put my question , in this way... there is a way to print without this conditional operator also.... try![]() thank u |
|
~ Б0ЯИ Τ0 С0δЭ ~
|
![]() |
| 25Sep2009,19:57 | #6 |
|
Then I would do it this way
![]() Code: CPP
|
|
Banned
|
|
| 26Sep2009,09:46 | #7 |
|
hmmmm
..in my question i already said without using arrays toooo u should do it!!!!!!!![]()
|
|
Mentor
|
![]() |
| 26Sep2009,12:23 | #8 |
|
Code:
printf("1 for odd, 0 for even -> %d \n",A&1);
|
|
Banned
|
|
| 26Sep2009,12:30 | #9 |
|
hmmmmmm this is the right answer.....
|
|
~ Б0ЯИ Τ0 С0δЭ ~
|
![]() |
| 26Sep2009,17:37 | #10 |