English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

given two numbers.how can you find the biggest of the two,without using conditional statements,relational operarors or ternary operators

2007-02-17 23:18:15 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

The mathematical formula is:
max(a,b)= (a + b + |a-b|)/2

in C:

long max(long a, long b){
return (a +b + abs(a-b))/2;
}

2007-02-18 00:02:39 · answer #1 · answered by Amit Y 5 · 1 0

double big, firstnumber,secondnumber;

big=max(firstnumber,secondnumber);

2007-02-18 08:14:57 · answer #2 · answered by iyiogrenci 6 · 0 1

fedest.com, questions and answers