@NemanNasawa If the domain of g(x) is R and it's defined by g(x)=cos(x), then the range can't be (-1, 1]. So the question doesn't make sense, as the function you specify doesn't exist.
If, however, the range is [-1, 1], with a square bracket on the left, then it does exist and it's surjective.
@NemanNasawa Do you know what (-1, 1] and [-1, 1] mean?