+ 1

What is this abs function of math.h

20th May 2017, 9:11 AM
Aditya Singh
Aditya Singh - avatar
4 Respostas
+ 13
y-x is -1, so abs(y-x) = abs(-1) = 1
20th May 2017, 10:53 AM
Shamima Yasmin
Shamima Yasmin - avatar
+ 10
abs gives you the distance from your number to 0; e.g abs from -5 would be 5 abs from 5 would be also 5
20th May 2017, 9:24 AM
Tim G
Tim G - avatar
+ 5
It represents the modulus function of mathematics, which is defined as: { x, if x>0 f(x) = { 0, if x=0 { -x, if x<0 y-x is <0, so it will be negative of y-x, which results in 1... Also note that abs is in stdlib.h, math.h has fabs which satisfies same purpose...
21st May 2017, 12:04 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
If x=5 and y=4 then z= abs(y-x) means.?
20th May 2017, 9:18 AM
Aditya Singh
Aditya Singh - avatar