Also, if we let a and b be real number with a<b then what is an example of a bounded f on [a,b] for which sup_[a,b] f is not achieved?

What would be an example of a bounded, continuous f on [a, ) for which sup_[a, ) f is not achieved?

and what would be an example of a bounded, continuous f on [a,b) for which sup_[a,b) f is not achieved?

For the first one would it be : f(x)= { x, a<=x<=b

0, x=b}

second, f(x)= -1/x+1

third, f(x)=x ?