consider this absolute value function.f(x) = |x-5|how can the function f be written as a piecewise function

Solution
By definition
[tex]|y|=\begin{cases}y,\text{ }y\ge0 \\ {} \\ {-y,\text{ }y<0}\end{cases}[/tex]Graphically, what |y| represents is
If y = x -5
[tex]\begin{gathered} \Rightarrow f(x)=|x-5|=\begin{cases}{x-5\text{ if }x-5\ge0} \\ {} \\ {-(x-5)\text{ if }x-5<0}\end{cases} \\ \\ \\ \operatorname{\Rightarrow}f(x)=\lvert x-5\rvert=\begin{cases}{x-5\text{ if }x\ge5} \\ {} \\ {-x+5\text{ if }x<5}\end{cases} \end{gathered}[/tex]The correct option is D.
To have a better understanding of it lets graw its graph