For any integer $n$, $a_n$ and $b_n$ are two real numbers and function....[CONT] 
For any integer $n$, $a_n$ and $b_n$ are two real numbers and function $$f(x)=\begin{cases} a_n + \sin \pi x & x\in [2n, 2n+1] \\\ b_n +\cos \pi x & x\in (2n-1,2n) \end{cases}$$ If $f(x)$ is continuous prove that $a_{n-1} - b_n=-1$

At $x=2n$,
$$f(2n) =a_n$$
And
$$\lim_{x \to 2n^-} b_n+\cos \pi x$$
$$=\lim _{h\to 0^+} b_n +\cos \pi (2n-h)$$
$$=\lim_{h\to 0^+} b_n +\cos \pi h$$
$$=b_n+1$$
So $$a_n-b_n=1$$
But I am not able to get $a_{n-1}$ in any expression. How should I do that?
Edit 
For the part I am not clear:
Why has the RHL been chosen as the second function at $x=2n+1$ and why does $b_n$ change to $b_{n+1}$?
 A: Normally, I would criticize if someone answered without explaining to the OP where he went wrong.  In this case however, the OP should be able to reverse engineer his mistake by using my answer.
At $x = (2n-1), \;f(x) = a_{(n-1)} + \sin \,\pi(2n-1) = a_{(n-1)}.$
As $x$ approaches $(2n-1)$ from above, 
$f(x)$ approaches $b_n + \cos(2n-1)\pi = b_n - 1.$
Since $f(x)$ is continuous at $x = (2n-1), \;b_n - 1 = a_{(n-1)}.$
Addendum: Response to Aditya's questions 
(1) 
When $x$ exactly equals $(2n+1), \;f(x) = a_n + \sin \,\pi(2n+1).$ 
Therefore, when $x$ exactly equals $(2[n-1] + 1),$ 
$f(x) = a_{[n-1]} \sin \,\pi(2[n-1]+1).$
(2) 
When $x \,\in \,(2n-1,2n) \;f(x) = b_n + \cos \,\pi(x).$ 
Note that when $x$ is approaching $(2n-1)$ from above, 
$x \,\in \,(2n-1,2n).$ 
This means that as $x$ is approaching $(2n-1)$ from above, 
$f(x)$ is approaching $b_n + \cos \,\pi (2n-1).$ 
Note that $\cos \,\pi (2n-1) \;=\; \cos \,(-\pi) = -1.$
.....
Please respond if I still have not answered your questions.
Addendum-2: Response to Aditya's added questions 
First of all, please see if you have a specific question about my original analysis (at the start of this answer),
as opposed to analysis that you originated or analysis that you got from
someone else.  If my analysis seems clear and valid to you, then my analysis
represents a solution.  That being said, I am happy to attack your questions.
(1) 
Why has the the RHL been chosen as the second function at $x = (2n + 1)$?
Go back to the basic definition: 
when $x \,\in (2n-1, 2n), \;f(x) = b_n + cos \pi(x).$
This means that when $x \,\in (2[n+1] - 1, 2[n+1]), \;f(x) = b_{[n+1]} + cos \pi(x).$ 
Note that $x = (2n+1) \Rightarrow x = (2[n+1] - 1).$
It looks like there is a typo in the statement that you are questioning.
Suppose that $0 < h < 1.$ 
Then $2n + 1 + h$ will be in $(2n + 1, 2n + 2),$ while 
$2n + 1 - h$ will instead be in $(2n, 2n + 1),$
This means that in order to make sense of the line that you are questioning,
you have to assume that $2n + 1 + h$ was intended.
(2) 
Why does $b_n$ change to $b_{(n+1)}.$
I repeat the pertinent part of what I said in (1):
Go back to the basic definition: 
when $x \,\in (2n-1, 2n), \;f(x) = b_n + cos \pi(x).$
This means that when $x \,\in (2[n+1] - 1, 2[n+1]), \;f(x) = b_{[n+1]} + cos \pi(x).$
.....
Again, please respond if I still have not answered your questions.  Also, I am particularly interested in your reaction to the analysis I gave at the start of my answer.
A: Hint:  You found the condition for $x$ even.  What about $x$ odd?  Notice that $2n-1 = 2(n-1)+1$, so you will be comparing the second piece in the definition of $f$ at $n$ with the first piece at $n-1$.
