Write a C function that receives three floatingpoint number

Write a C function that receives three floating-point number as input argument. The function returns the value of the one with the maximum absolute value. For example, if the numbers are 12.1, -13.2, and 0.1, respectively, then the function will return -13.2 because it has the maximum absolute value of 13.2. You are not allowed to use abs() function of C standard libraries.

Solution

float abs (float n1, float n2, float n3) {
float s,s1,s2;
return n1 < 0 ? -n1 : n1;
s1=n1 < 0 ? -n2 : n2;
s2=n1 < 0 ? -n3 : n3;
if (s>s1 && s>s2)
return s;
else if(s1>s && s1>s)
return s1;
else
return s;
}

 Write a C function that receives three floating-point number as input argument. The function returns the value of the one with the maximum absolute value. For

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site