Answer :
A uniformly distributed random variable on the interval [tex][a,b][/tex] will have a constant positive value for point within the given interval, and zero elsewhere. This constant satisfies
[tex]\displaystyle\int_{-\infty}^\infty f_X(x)\,\mathrm dx=\int_a^b c\,\mathrm dx=1[/tex]
Integrating, you get
[tex]\displaystyle\int_a^b c\,\mathrm dx=cx\bigg|_{x=a}^b=c(b-a)=1\implies c=\dfrac1{b-a}[/tex]
So the density function is
[tex]f_X(x)=\begin{cases}\dfrac1{b-a}&\text{for }a\le x\le b\\[1ex]0&\text{otherwise}\end{cases}[/tex]
[tex]\displaystyle\int_{-\infty}^\infty f_X(x)\,\mathrm dx=\int_a^b c\,\mathrm dx=1[/tex]
Integrating, you get
[tex]\displaystyle\int_a^b c\,\mathrm dx=cx\bigg|_{x=a}^b=c(b-a)=1\implies c=\dfrac1{b-a}[/tex]
So the density function is
[tex]f_X(x)=\begin{cases}\dfrac1{b-a}&\text{for }a\le x\le b\\[1ex]0&\text{otherwise}\end{cases}[/tex]