Question: Please fix this using C Language and the Output should be correct and add more data about student such as No. ID, Student Name, CGPA,
Please fix this using C Language and the Output should be correct and add more data about student such as No. ID, Student Name, CGPA, Email, Programme, No. Phone #include
void add();
void delete();
void update();
void list();
void search();
int size = 12;
float cgpa[12];
char email[12],program[12],studname[20];
int studId[12], phnum[12], operation, stop;
int main()
{
do{
stop=0;
printf(" ---------->Welcome to the Student Information System<---------- ");
printf("=================================================================== "); printf("What is the operation that you want to execute? "); printf("1) Add the student ");
printf("2) Delete the student ");
printf("3) Update the student ");
printf("4) List of the student(s) ");
printf("5) Search the student ");
printf(" Operation : ");
scanf("%i", &operation);
if(operation == 1)
{
printf(" You choose to add the student. ");
add();
}
else if(operation == 2)
{
printf(" You choose to delete the student. ");
delete();
}
else if(operation == 3)
{
printf(" You choose to update the student. ");
update();
}
else if(operation == 4)
{
printf(" You choose to view the list of the student(s). "); list();
}
else if(operation == 5)
{
printf(" You choose to search the student. ");
search();
}
else
{
printf(" The number that you enter is incorrect. "); }
printf(" Do you want to continue? Press 1 to continue. "); scanf("%d", &stop);
}while(stop==1);
return 0;
}
void add()
{
int position =0, studValidate=0, exist=0;
for(int x=0; x if(studId[x]==0){ position = x; break; } } printf(" Enter the student ID. (11 digits including AIU UNIQUE ID) : "); scanf("%d", &studValidate); for(int y=0; y if(studId[y]==studValidate){ printf("The student ID. is already exist. "); exist =1; break; } } if(exist ==0){ studId[position]= studValidate; printf("Enter the student phone number : "); scanf("%d", &phnum[position]); fflush(stdin); printf("Enter student name : "); scanf("%s", &studname[position]); fflush(stdin); printf("Enter the student program : "); scanf("%s", &program[position]); fflush(stdin); printf("Enter the student email : "); scanf("%s",&email[position]); fflush(stdin); printf("Enter the student CGPA : "); scanf("%e",&cgpa[position]); fflush(stdin); printf("The student is successfully added."); } } void delete() { int studIdDelete,position,found=0; printf(" Enter the ID No. of the student that you want to delete : "); scanf("%d", &studIdDelete); for(int x=0; x if(studId[x]==studIdDelete){ position = x; break; } } printf(" ---------->List of the student(s)<---------- "); printf("============================================= "); printf(" No. ID No. Phone "); printf("============================================= "); for(int x=0; x if(studId[x]==studIdDelete){ printf(" %d %d %d ",x+1,studId[x],phnum[x]); printf(" student is deleted. "); found=1; break; } }if(found !=1){ printf(" The book is not deleted. "); } } void update() { int stuidUpdate,position, phnumUpdate,found=0; printf(" Enter the ID No.of the student that you want to update : "); scanf("%d", &stuidUpdate); printf(" Enter the phone number of the student that you want to update : "); scanf("%d", &phnumUpdate); for(int x=0; x if(studId[x]==phnumUpdate){ position = x; break; } } for(int x=position; x if(studId[x]==stuidUpdate){ phnum[x] = phnumUpdate; } else { break; } } printf(" ---------->List of the student(s)<---------- "); printf("============================================= "); printf(" No. ID No. phone "); printf("============================================= "); for(int y=0; y if(studId[y]==stuidUpdate){ printf(" %d %d %d ",y+1,studId[y],phnum[y]); printf(" The student is updated. "); found=1; break; } } if(found !=1){ printf(" The student is not updated. "); } } void search() { int studIdSearch,position, found=0; printf(" Enter the ID No. of the student that you want to search : "); scanf("%d", &studIdSearch); for(int x=0; x if(studId[x]==studIdSearch){ position = x; break; } } printf(" ---------->List of the student(s)<---------- "); printf("============================================= "); printf(" No. ID No. phone "); printf("============================================= "); for(int y=0; y if(studId[y]==studIdSearch){ printf(" %d %d %d ",y+1,studId[y],phnum[y]); printf(" The student is found. "); found=1; break; } } if(found !=1){ printf(" The student is not found. "); } } void list() { printf(" ---------->List of the student(s)<---------- "); printf("============================================= "); printf(" No. ID No. Phone CGPA Email Program Name "); printf("============================================= "); for(int y=0; y if(studId[y]==0) { break; } printf(" %d %d %d %f %s %s %s ",y+1,studId[y],phnum[y],cgpa[y],email[y],program[y],studname[y]); } printf(" All of the student are listed. "); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
