a and b are compared against the threshold ‘TH’, and the nearest value is voted as output
int compare (int a, int b, int th) { if (abs(th - a) > abs(th-b)) return b; else return a; }
if a and b both are at the same distance from th then a is returned.
How can I wwap value two variables without using third variable or +/- operator?
input: one two three
output: three two one
Input : Query Home is a good website
Output: Query Home is a very good website
It was asked today in interview but could not crack it, any help.