Constructing Context Free Grammar
Hint: try to do each language separately, and then your final grammar is S->S1|S2|S3.

To do your case 2, you can write

$S-&gt;aSc|X$

$X-&gt;aXb|\epsilon$.

I.e. you start by generating the c's and the exceeding a's, and then you generate the b's and the remaining a.