OneCompiler

my assigment Here is my assigment coding for calculate gpa and cgpa and i have face some error can anyone help me to solve the error it will show this Unhandled exception at 0x00007FF696DC38F7 in cassigment.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x00000036C2CF3000).beside the int main(){ after it have run.

170

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#pragma warning(disable:4996)

struct Course {
char code[20];
int credithours;
char grade[3];
};
struct student {
char name[50], id[10], coursecode[20];
int semester, numcourse, numStudent, credithours;
struct Course courses[6];
float gpa;
};
void main() {
//Welcome & greeting screen
printf(" ### ### #### ### ########## ########## ###### ## ######## ## ########\n");
printf(" ### ### ## ## ### #### ## ### ## #### ####### #### ## ###\n");
printf(" ### ### ## ## ### ### ## ### ## ## ## #### ## ## ## ###\n");
printf(" ##### ## ## ### ########## ## ### ## ## ## ######## ## ## ######\n");
printf(" ### ### ## ## ### ### ## ## ###### ########## #### ########## ### ##\n");
printf(" ### ### ## ## ### #### ## ## ### ### ### ###### ### ### ### ##\n");
printf(" ### ### #### ########## ########## ##### ### ### ### ######## ### ### ### ##\n");

printf("\n\n\n");


//variable
char staff[50], id[10], grade[3];
int mode, semester, numcourse, credithours, totalcredithours = 0, numStudent, credithours1;
float gpa = 0.0, cgpa = 0.0, gradePoint, qualitypoint, totalqualitypoint = 0.0;



//Menu processing
int menu1;
char name[50];
struct student students[5000];

do {

	printf("\n         Please select the mode:\n");
	printf("\n+=========================================+\n");
	printf("||1. Kolej Pasar staff administrator mode||\n");
	printf("||2.       Kolej Pasar student mode      ||\n");
	printf("||3.                Exit                 ||\n");
	printf("+=========================================+\n");
	printf("Please enter your choice: ");
	scanf_s("%d", &menu1);


	switch (menu1)
	{
	case 1:


		printf("\n\nEnter the number of students that you want to record data:");
		scanf("%d", &numStudent);

		if (numStudent <= 0 || numStudent > 5000) {
			printf("Limited to 5,000 students only\n");
			return 1;
		}
		else {
			for (int i = 0; i < numStudent; i++) {
				printf("Enter student's details:\n");
				printf("Student Name: ");
				scanf(" %49[^\n]", students[i].name);

				printf("Student's id(format:KPKL12345): ");
				scanf("%9s", students[i].id);

				printf("Enter current semester: ");
				scanf("%d", &students[i].semester);

				printf("Enter the number of courses for this student: ");
				scanf("%d", &students[i].numcourse);

				for (int j = 0; j < students[i].numcourse; j++) {
					printf("Enter course code for course %d: ", j + 1);
					scanf("%s", students[i].courses[j].code);




					printf("\n+====================+\n");
					printf("||Grade||Grade Point||\n");
					printf("||=====||===========||\n");
					printf("||  A  ||    4.00   ||\n");
					printf("||  A- ||    3.75   ||\n");
					printf("||  B+ ||    3.50   ||\n");
					printf("||  B  ||    3.00   ||\n");
					printf("||  B- ||    2.75   ||\n");
					printf("||  C+ ||    2.50   ||\n");
					printf("||  C  ||    2.00   ||\n");
					printf("||  F  ||    0.00   ||\n");
					printf("+====================+\n");

					printf("\n+=========================+\n");
					printf("||Course Code|Credir Hour||\n");
					printf("||===========|===========||\n");
					printf("||Semester 1 |           ||\n");
					printf("||=======================||\n");
					printf("||1.AAA1003  |    3      ||\n");
					printf("||2.AAA1014  |    4      ||\n");
					printf("||=======================||\n");
					printf("||Semester 2 |           ||\n");
					printf("=========================||\n");
					printf("||3.ABA1003  |    3      ||\n");
					printf("||4.ABA1014  |    4      ||\n");
					printf("||=======================||\n");
					printf("||Semester 3 |           ||\n");
					printf("||5.ACA1003  |    3      ||\n");
					printf("||6.ACA1014  |    4      ||\n");
					printf("+=========================+\n");



					printf("Enter grade obtained for course %s: ", students[i].courses[j].code);
					scanf("%s", students[i].courses[j].grade);
					if (strcmp(grade, "A") == 0) {
						printf("Grade Point = 4.00\n");
						gradePoint = 4.00;
					}
					else if (strcmp(grade, "A-") == 0) {
						printf("Grade Point = 3.75\n");
						gradePoint = 3.70;
					}
					else if (strcmp(grade, "B+") == 0) {
						printf("Grade Point = 3.50\n");
						gradePoint = 3.50;
					}
					else if (strcmp(grade, "B") == 0) {
						printf("Grade Point = 3.00\n");
						gradePoint = 3.00;
					}
					else if (strcmp(grade, "B-") == 0) {
						printf("Grade Point = 2.75\n");
						gradePoint = 2.75;
					}
					else if (strcmp(grade, "C+") == 0) {
						printf("Grade Point = 2.50\n");
						gradePoint = 2.50;
					}
					else if (strcmp(grade, "C") == 0) {
						printf("Grade Point = 2.00\n");
						gradePoint = 2.00;
					}
					else if (strcmp(grade, "F") == 0) {
						printf("Grade Point = 0.00\n");
						gradePoint = 0.00;
					}
					else {
						printf("ERROR\n");
						return 1;
					}

					printf("Enter credit hours for course %s: ", students[i].courses[j].code);
					scanf("%d", &students[i].courses[j].credithours);





					qualitypoint = gradePoint * students[i].credithours;
					totalqualitypoint += qualitypoint;
					totalcredithours += students[i].credithours;
					students[i].gpa = totalqualitypoint / totalcredithours;
				}
				cgpa = students[i].gpa;
			}

			printf("\nGPA:%.2f\n", gpa);
			printf("cgpa:%.2f\n", cgpa);
		}
		break;

	case 2:
		printf("\nStudent's id(format:KPKL12345):");
		scanf("%s", id);

		int studentIndex = -1;
		for (int i = 0; i < numStudent; i++) {
			if (strcmp(students[i].id, id) == 0) {
				studentIndex = i;
				break;
			}
		}

		if (studentIndex == -1) {
			printf("Student not found\n");
		}
		else {
			printf("Student Name: %s\n", students[studentIndex].name);

			int menu2;
			printf("\nPlease select the mode:\n");
			printf("\n+=========================================+\n");
			printf("||1. View student GPA                   ||\n");
			printf("||2. View student CPGA                  ||\n");
			printf("||3. Back                              ||\n");
			printf("+=========================================+\n");
			printf("\nPlease enter your choice:");
			scanf("%d", &menu2);

			if (menu2 == 1) {
				printf("\nYour GPA: %.2f\n", students[studentIndex].gpa);
			}
			else if (menu2 == 2) {
				printf("\nYour CPGA: %.2f\n", cgpa);
			}
			else if (menu2 != 3) {
				printf("Invalid choice\n");
			}
		}
		break;

	case 3:
		printf("Exiting the program...\n");
		break;

	default:
		printf("Invalid choice. Please select the mode between 1 - 3.\n");
		break;
	}

} while (menu1 != 3);

return 0;

}