It is a very easy problem.
Needs 2 loops, 1 for test cases another one for number of courses and some if else conditions to check the gpa of the courses.
Input the numeral grade or marks and credit of your courses.Calculate the CGPA by this way.....
Find the summation of GPA for all the courses(i. e. sum += gpa*credit) and divide the sum by the summation of all the credits of your courses.