Add and first inti c sbn projects ass
This commit is contained in:
7
work1/course_tag.h
Normal file
7
work1/course_tag.h
Normal file
@@ -0,0 +1,7 @@
|
||||
struct course_tag
|
||||
{
|
||||
char course_name[20];
|
||||
int no_of_units;
|
||||
int marks[4];
|
||||
float avg;
|
||||
};
|
||||
27
work1/function.c
Normal file
27
work1/function.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "stdio.h"
|
||||
#include "stdio.h"
|
||||
#include "./student_tag.h"
|
||||
|
||||
void display() {
|
||||
printf("display...");
|
||||
}
|
||||
|
||||
void search(int mark) {
|
||||
printf("search mark...");
|
||||
}
|
||||
|
||||
void find_largest_average() {
|
||||
printf("find largest average...");
|
||||
}
|
||||
|
||||
void find_failed_students() {
|
||||
printf("find failed students...");
|
||||
}
|
||||
|
||||
void add_new(struct student_tag student) {
|
||||
printf("add new...");
|
||||
}
|
||||
|
||||
void quite() {
|
||||
exit(1);
|
||||
}
|
||||
9
work1/function.h
Normal file
9
work1/function.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "stdlib.h"
|
||||
#include "./student_tag.h"
|
||||
|
||||
void display();
|
||||
void search(int mark);
|
||||
void find_largest_average();
|
||||
void find_failed_students();
|
||||
void add_new(struct student_tag student);
|
||||
void quite();
|
||||
36
work1/main.c
Normal file
36
work1/main.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "./../util/constants.h"
|
||||
#include "./../util/utils.c"
|
||||
#include "./menu.c"
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("\nInitializing program...\n");
|
||||
clrscr();
|
||||
|
||||
char c;
|
||||
FILE *file;
|
||||
|
||||
// check the file has load or not
|
||||
// if not load correctly or file not, it must be exit the program
|
||||
if ((file = fopen(WELCOME_FILE_DATA, "r")) == NULL)
|
||||
{
|
||||
printf("Cannot open file!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// read the file into output screen
|
||||
// if it's not meet the end of file it will run till the end of data
|
||||
while ((c = getc(file)) != EOF)
|
||||
{
|
||||
printf("%c", c);
|
||||
}
|
||||
|
||||
// close the welcome file
|
||||
fclose(file);
|
||||
|
||||
// show menu
|
||||
menu();
|
||||
|
||||
}
|
||||
50
work1/menu.c
Normal file
50
work1/menu.c
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "stdio.h"
|
||||
#include "./function.c"
|
||||
#include "./../util/define.h"
|
||||
#include "./student_tag.h"
|
||||
#include "./person_tag.h"
|
||||
|
||||
void menu()
|
||||
{
|
||||
printf("\n\n\n-------------------MENU-------------------\n");
|
||||
printf("\n(1) Display students’ details\n");
|
||||
printf("\n(2) Search for a student’s mark\n");
|
||||
printf("\n(3) Find the details of student with the largest average\n");
|
||||
printf("\n(4) Find the details of failed students\n");
|
||||
printf("\n(5) Add new student to the record\n");
|
||||
printf("\n(6) Quit program\n\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void choose_menu(int menu)
|
||||
{
|
||||
|
||||
switch (menu)
|
||||
{
|
||||
case MENU_1:
|
||||
display();
|
||||
break;
|
||||
case MENU_2:
|
||||
search(1);
|
||||
break;
|
||||
case MENU_3:
|
||||
find_largest_average();
|
||||
break;
|
||||
case MENU_4:
|
||||
find_failed_students();
|
||||
break;
|
||||
case MENU_5:
|
||||
|
||||
struct person_tag info = {"1","Sambo"};
|
||||
struct student_tag std = {.student_info = info};
|
||||
add_new(std);
|
||||
break;
|
||||
case MENU_6:
|
||||
quite();
|
||||
break;
|
||||
default:
|
||||
printf("not found!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
5
work1/person_tag.h
Normal file
5
work1/person_tag.h
Normal file
@@ -0,0 +1,5 @@
|
||||
struct person_tag
|
||||
{
|
||||
char name[20];
|
||||
char id[10];
|
||||
};
|
||||
9
work1/student_tag.h
Normal file
9
work1/student_tag.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "./person_tag.h"
|
||||
#include "./course_tag.h"
|
||||
|
||||
struct student_tag
|
||||
{
|
||||
struct person_tag student_info;
|
||||
struct course_tag course_info;
|
||||
struct student_tag *next;
|
||||
};
|
||||
Reference in New Issue
Block a user