Blog Archives

A CGPA calculator for Kerala University Btech(2008 Scheme)


This C program calculate the CGPA if the GPAs of each semseter is Entered. Compile and run this program. This caclculator is based on Jerala University Btech 2008 scheme. This program was done for pure fun, I had a php version but as I formated my system lost it.

/** By Vineeth Kartha released under GPL**/
#include<stdio.h>
int main()
{
  float gpa[8],cgpa=0,intgpa=0;
  int crd12=58,crd=29,crdtot=0;;
  int sem;
  int i;
  printf("Enter number of semsters till which CGPA is to be calculated :  ");
  scanf("%d",&sem);
  if(sem==1)
    {
      sem=2;
    }
  while(sem<1||sem>8)
    {
      printf("Please Enter valid number of  semesters(1-8)");
      scanf("%d",&sem);
    }
  for(i=2;i<=sem;i++)
    {
      if(i==2)
    {
      printf("Enter the GPA of S12:  ");
      scanf("%f",&gpa[0]);
      gpa[1]=0;//since S12 mark is taken twice.
      gpa[0]=gpa[0]*crd12;
      gpa[1]=gpa[1]*crd12;
      crdtot=crd12;
      intgpa=gpa[0]+gpa[1];
    }
      else
    {
      printf("Enter the GPA of S%d:  ",i);
      scanf("%f",&gpa[i-1]);
      gpa[i-1]=gpa[i-1]*crd;
      crdtot+=crd;
      intgpa+=gpa[i-1];
    }
    }
  cgpa=intgpa/crdtot;
  printf("\n The CGPA till Semster %d is   %0.2f\n",sem,cgpa);
  return 0;
}
%d bloggers like this: