Skip to content

Instantly share code, notes, and snippets.

@maruf-sarker
Last active August 2, 2022 18:40
Show Gist options
  • Save maruf-sarker/c22178a8d94a540518d83466c5b04203 to your computer and use it in GitHub Desktop.
Save maruf-sarker/c22178a8d94a540518d83466c5b04203 to your computer and use it in GitHub Desktop.
SGPA Calculator Project - Md. Maruf Sarker - Green University Of Bangladesh - Dedicated to Suborno Maksuda - Dhaka International University
// Project Name: SGPA Calculator
// Author: Md. Maruf Sarker
// Date: 3 August, 2022
// Language: C
// Version: 1.0
// Green University of Bangladesh - 221 Batch
// Time Spend: 10:00 pm -12:40 am
#include <stdio.h>
float grade(float num, float credit, float grade){
if(num > 0 && num < 40){
printf("\t\t Grade: F and Grade Point: 0.00\n");
grade = 0.00 * credit;
}else if(num >= 40 && num < 45){
printf("\t\tGrade: D and Grade Point: 2.00\n");
grade = 2.00 * credit;
}else if(num >= 45 && num < 50){
printf("\t\tGrade: (C Regular) and Grade Point: 2.25\n");
grade = 2.25 * credit;
}else if(num >= 50 && num < 55){
printf("\t\tGrade: (C Plus) and Grade Point: 2.50\n");
grade = 2.50 * credit;
}else if(num >= 55 && num < 60){
printf("\t\tGrade: (B Minus) and Grade Point: 2.75\n");
grade = 2.75 * credit;
}else if(num >= 60 && num < 65){
printf("Grade: (B Regular) and Grade Point: 3.00\n");
grade = 3.00 * credit;
}else if(num >= 65 && num < 70){
printf("\t\tGrade: (B Plus) and Grade Point: 3.25\n");
grade = 3.25 * credit;
}else if(num >= 70 && num < 75){
printf("\t\tGrade: (A minus) and Grade Point: 3.50\n");
grade = 3.50 * credit;
}else if(num >= 75 && num < 80){
printf("\t\tGrade: (A regular) and Grade Point: 3.75\n");
grade = 3.75 * credit;
}else if(num >= 80 && num <= 100){
printf("\t\tGrade: (A plus) and Grade Point: 4.00\n");
grade = 4.00 * credit;
}
return grade;
}
int main(){
int i = 0;
float n1,n2,n3,n4,n5;
float gd = 0.0,grade1,grade2,grade3,grade4,grade5,total_grade = 0.0,sgpa = 0.0;
printf("\t\t\t\tMost Welcome!\n");
printf("\t\tPlease enter the marks obtained in each subject:\n\n ");
// CSE-103
condition1:
printf("Course Code:(CSE-103); Course Title: Structured Programming; Credit(s):(3): ");
scanf("%f",&n1);
if(n1 < 0 || n1 > 100){
printf("\n\t\tIt is an invalid number.Please input number between 1 to 100 again.\n");
goto condition1;
}
if(n1 > 0 || n1 < 100){
grade1 = grade(n1,3,gd);
}
if(n1 > 0 && n1 < 40){
i++;
}
// CSE-104
condition2:
printf("\nCourse Code:(CSE-104); Course Title: Structured Programming Lab; Credit(s):(1): ");
scanf("%f",&n2);
if(n2 < 0 || n2 > 100){
printf("\n\t\tIt is an invalid number.Please input number between 1 to 100 again.\n");
goto condition2;
}
if(n2 > 0 || n2 < 100){
grade2 = grade(n2,1,gd);
}
if(n2 > 0 && n2 < 40){
i++;
}
// PHY-103
condition3:
printf("\nCourse Code:(PHY-103); Course Title: Electricity and Magnetism; Credit(s):(3): ");
scanf("%f",&n3);
if(n3 < 0 || n3 > 100){
printf("\n\t\tIt is an invalid number.Please input number between 1 to 100 again.\n");
goto condition3;
}
if(n3 > 0 || n3 < 100){
grade3 = grade(n3,3,gd);
}
if(n3 > 0 && n3 < 40){
i++;
}
// PHY-104
condition4:
printf("\nCourse Code:(PHY-104); Course Title: Electricity and Magnetism Lab; Credit(s):(1): ");
scanf("%f",&n4);
if(n4 < 0 || n4 > 100){
printf("\n\t\tIt is an invalid number.Please input number between 1 to 100 again.\n");
goto condition4;
}
if(n4 > 0 || n4 < 100){
grade4 = grade(n4,1,gd);
}
if(n4 > 0 && n4 < 40){
i++;
}
// MAT-101
condition5:
printf("\nCourse Code:(MATH-101); Course Title: Linear Algebra & Co-ordinate Geometry; Credit(s):(3): ");
scanf("%f",&n5);
if(n5 < 0 || n5 > 100){
printf("\n\t\tIt is an invalid number.Please input number between 1 to 100 again.\n");
goto condition5;
}
if(n5 > 0 || n5 < 100){
grade5 = grade(n5,3,gd);
}
if(n5 > 0 && n5 < 40){
i++;
}
total_grade = grade1 + grade2 + grade3 + grade4 + grade5;
sgpa = total_grade / 11.00;
if(i == 1 || i == 2) printf("Incomplete Course\n");
else if(i== 3 || i == 4 || i == 5) printf("Re-admission Please\n");
else if(i == 0) printf("\n\n\n\t\tThe SGPA of this student is :%.2f\n ",sgpa);
printf("\n\t\t\t\t\tThank you!\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment