Updated for student details and add goto label for enter course units again
This commit is contained in:
parent
9aa3dc2919
commit
aabb594c70
@ -6,3 +6,24 @@ Computer
|
|||||||
98
|
98
|
||||||
52
|
52
|
||||||
95
|
95
|
||||||
|
SS
|
||||||
|
323
|
||||||
|
SC
|
||||||
|
3
|
||||||
|
2
|
||||||
|
4
|
||||||
|
2
|
||||||
|
Sambo2
|
||||||
|
73823
|
||||||
|
MSK2
|
||||||
|
3
|
||||||
|
3
|
||||||
|
54
|
||||||
|
2
|
||||||
|
SS
|
||||||
|
SS3
|
||||||
|
212
|
||||||
|
3
|
||||||
|
5
|
||||||
|
3
|
||||||
|
2
|
@ -2,6 +2,7 @@
|
|||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
|
||||||
#define BUFFER_SIZE 128
|
#define BUFFER_SIZE 128
|
||||||
|
#define MAX_NO_OF_UNITS 4
|
||||||
|
|
||||||
const char *FILE_STUDENT_DATA_PATH = "./data/students.test.txt";
|
const char *FILE_STUDENT_DATA_PATH = "./data/students.test.txt";
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ struct course_tag
|
|||||||
{
|
{
|
||||||
char course_name[20];
|
char course_name[20];
|
||||||
int no_of_units;
|
int no_of_units;
|
||||||
int marks[4];
|
int marks[MAX_NO_OF_UNITS];
|
||||||
float avg;
|
float avg;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ void read_file();
|
|||||||
void quite();
|
void quite();
|
||||||
|
|
||||||
// Linked list functions
|
// Linked list functions
|
||||||
void add_student(char student_name[20], char student_id[10], char course_name[20], int no_of_units, int marks[4]);
|
void add_student(char student_name[20], char student_id[10], char course_name[20], int no_of_units, int marks[MAX_NO_OF_UNITS]);
|
||||||
int count();
|
int count();
|
||||||
|
|
||||||
// util functions
|
// util functions
|
||||||
@ -110,10 +111,13 @@ void display_students()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("\n================ Student Details ================\n");
|
||||||
|
|
||||||
print_student(student);
|
print_student(student);
|
||||||
|
|
||||||
while (student->next != NULL)
|
while (student->next != NULL)
|
||||||
{
|
{
|
||||||
|
printf("\n");
|
||||||
student = student->next;
|
student = student->next;
|
||||||
print_student(student);
|
print_student(student);
|
||||||
}
|
}
|
||||||
@ -145,7 +149,7 @@ void display_menu()
|
|||||||
printf("(6) Quit program\n\n");
|
printf("(6) Quit program\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_student(char student_name[20], char student_id[10], char course_name[20], int no_of_units, int marks[4])
|
void add_student(char student_name[20], char student_id[10], char course_name[20], int no_of_units, int marks[MAX_NO_OF_UNITS])
|
||||||
{
|
{
|
||||||
STUDENT *temp, *iterator;
|
STUDENT *temp, *iterator;
|
||||||
temp = (struct student_tag *)malloc(sizeof(struct student_tag));
|
temp = (struct student_tag *)malloc(sizeof(struct student_tag));
|
||||||
@ -312,7 +316,7 @@ void update_file()
|
|||||||
char id[10];
|
char id[10];
|
||||||
char course_name[20];
|
char course_name[20];
|
||||||
int no_of_units;
|
int no_of_units;
|
||||||
int marks[4];
|
int marks[MAX_NO_OF_UNITS];
|
||||||
|
|
||||||
printf("Enter student name: ");
|
printf("Enter student name: ");
|
||||||
scanf("%s", &name);
|
scanf("%s", &name);
|
||||||
@ -323,9 +327,16 @@ void update_file()
|
|||||||
printf("Enter course name: ");
|
printf("Enter course name: ");
|
||||||
scanf("%s", &course_name);
|
scanf("%s", &course_name);
|
||||||
|
|
||||||
|
again:
|
||||||
printf("Enter no of units: ");
|
printf("Enter no of units: ");
|
||||||
scanf("%d", &no_of_units);
|
scanf("%d", &no_of_units);
|
||||||
|
|
||||||
|
if (no_of_units > MAX_NO_OF_UNITS) {
|
||||||
|
printf("you cannot input the units bigger than %d\n", MAX_NO_OF_UNITS);
|
||||||
|
getchar();
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < no_of_units; i++)
|
for (int i = 0; i < no_of_units; i++)
|
||||||
{
|
{
|
||||||
printf("Enter mark[%d]: ", i + 1);
|
printf("Enter mark[%d]: ", i + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user