Bravo
Actually, this wasn't really an example. It was your exerciseFollowing your extremely clear example, I found that c=2.
In other problems, you may have different boundaries. The boundaries for the integrals form the region where the pdf is not 0. That's what you have to remember.
Sometimes, you can be given a function f(x)=cg(x), in the interval [a,b] and be asked to find c such that f is a pdf.
In which case, integrate from a to b and find c such that the integral is 1.
Same principle as above, though different question
I hope it will help you in the future.