![]() |
To find a>b or a<b without using of Logical & relational Operators!!!
Program to find max(x,y) or Min(x,y) without using any relational and logical operator.
Code: C
Code: C
Code: C
|
Re: To find a>b or a<b without using of Logical & relational Operators!!!
Looks like there is some problem in your code where you have not defined num
|
Re: To find a>b or a<b without using of Logical & relational Operators!!!
That's pretty neat, the perhaps not universally portable.
Your code does better than just avoiding relational and logical operators, it also avoids conditional (and loop) statements (including ?: ). Here's a re-write: Code:
#include <limits.h> /* for CHAR_BIT: number of bits in a char */that assumes (minimally) that x has a lower address than y. The method is already making an assumption about manipulating the sign bit that may not work on all computers. I also found your MinimumOf and MaximumOf interesting: Code:
/* Fill n with its sign bit, becoming all 1's or 0's */ |
Re: To find a>b or a<b without using of Logical & relational Operators!!!
Quote:
Very Very Sorry for this mistake. correct code will be Code: C Code:
int maximum(int x, int y) |
Re: To find a>b or a<b without using of Logical & relational Operators!!!
I have updated the above article but learn to use the code block in the posts - Before you make a query
|
| All times are GMT +5.5. The time now is 07:01. |