The simplest way to caculate the C.G.P.A is to Add up your SGPA for all semester then divide it by the no. of semesters for which CGPA is to be calculated.
CGPA = Sum of All SGPA/No.Of Semester
Now SGPA for a semester can be calculated by multiplying the acquired grade point with The Credit of the subject and summing up this product for all the subject,then divide whole sum by total credits of the subjects
SGPA = Credit points X Grade points(INDIVIDUALLY FOR ALL SUBJECTS) /Sum of Credit points