p$th$,q$th$ and r$th$ term are $q, p, p+q-r$ respectively.
$a_{p}= a+(p-1)d = q$
$= a+pd-d=q$
$a_{q} = a+(q-1)d = p$
$=a+qd-d=p$
Now for getting common difference we should minus 2nd term from first term that means p$th$ term minus q$th$ term. which is
$a_{q}-a_{p}$ $\Rightarrow$ d = 1
But in my book it is given
$a_{p}-a_{q}$
after solving
$\Rightarrow$ $ d = 1$
Now I want to understand the complete answer.
$a_{p}= a+(p-1)d = q$ and $a_{q}= a+(q-1)d = p$.
Solving these two you get that $(p-q)d=q-p\implies d=-1$.
Just putting $d=-1$ in $a_{p}= a+(p-1)d = q$ yield that $a=p+q-1$.
$a_r= a_(r-1)d=p+q-1+(r-1)\times -1=p+q-r$
$a_{p+q}=a+(p+q-1)d=p+q-1+(p+q-1)\times -1=0$