The formula for GPA calculation is:
GPA = Sum of credits scored/Total number of credits
Credit scored = Grade point scored * Number of credits in the course.
For e.g. you get a B grade in a 2 credit couse, your credit score will be 16 (8 x 2) as B grade corresponds to 8 grade points. The sum of all these credit scores divided by the total credits taken gives the GPA of the given semester.