The assignment _________________________________________________________________
ID: 3618133 • Letter: T
Question
The assignment____________________________________________________________________________________
Following code to be written in C
You are required to create a student management system that willallow
you to store and update student records. Each student recordshould
consist of
an id, a name (first name and last name), date of
birth,address,telephone
number and the program being pursued.
Assume 10 records will be stored.
1. Create and populate an
array of records. Store records into file.
2. Allow user to update a record. Note, the user should onlymanipulate the data structure.
All changes to the data structure should then be used to
overwrite the file.
3. Allow user to search for a record from the data structure.
4. Print all records from the structure.
N.B.Student should Create Appropriatefunctions to
solve the problem.
edit the C programming so that it can save its INPUTS sothat the records will be
saved in a
file example ( studentrecords.txt ) so that it can be accessedlater..so when the program closes and start up
back, there will be the same records from the files, enteredpreviously
......
To make the program updaterecords
____________________________________________________________________________________
#include<stdio.h>
#include<conio.h>
struct SMS
{int id;
char first[15];
char last[15];
char dob[11];
char phone[15];
char program[20];
}stu[10];
int create(struct SMS[],int);
int search(struct SMS[],int );
void update(struct SMS[],int);
void print(struct SMS[],int);
void printstudent(struct SMS[],int,int);
int menu();
int main()
{int choice,n=0,m;
for(;;)
{
choice=menu();
switch (choice)
{case 1: n=create(stu,n);break;
case 2:update(stu,n);break;
case 3: m=search(stu,n);
if(m>=n)
printf("student not in data base ");
else
printstudent(stu,n,m);
break;
case 4: print(stu,n);break;
case 5: return 0;
}
}
getch();
return 0;
}
int menu()
{int choice;
printf(" *~*~*~*WeLcome To Dwayne Brown's And Mohit Belani'sProgram*~*~*~* ");
printf("What would you like to do to the database? ");
printf("1. Create 2. Update 3. Search 4. Print 5. Quit Enterchoice: ");
scanf("%d",&choice);
while(choice<1||choice>5)
{printf("Invalid entry ");
printf("What would you like to do to thedatabase? ");
printf("1. create 2. update 3.search 4. print 5. Quit Enter choice: ");
scanf("%d",&choice);
}
return choice;
}
int create(struct SMS stu[],int n)
{
int i=n;
printf("Enter id(<0 when done): ");
scanf("%d",&stu[i].id);
while(stu[i].id>0)
{
printf("Enter last name: ");
scanf("%s",&stu[i].last);
printf("Enter first name: ");
scanf("%s",&stu[i].first);
printf("Enter date of birth (mm/dd/yyyy):");
scanf("%s",&stu[i].dob);
printf("Enter phone number ((xxx)-xxx-xxxx):");
scanf("%s",&stu[i].phone);
printf("Enter program of study: ");
scanf("%s",&stu[i].program);
i++;
printf(" Record of Student Saved. ");
printf(" You May Continue to Enter a anotherstudent record or exit with ( <0 ): ");
printf(" Enter ID for new student(<0 whendone): ");
scanf("%d",&stu[i].id);
}
return i;
}
void update(struct SMS stu[],int u)
{
inti,n,newid,idu=0,firstu=0,lastu=0,dobu=0,phoneu=0,programu=0;
printf("Enter ID of student to update: ");
scanf("%d",&u);
while(u==stu[i].id)
{
printf("student infomation: ID : %s Fullname: %s %s d.o.b: %s phone number:%s program:%s",stu[i].id,stu[i].first,stu[i].last,stu[i].dob,stu[i].phone,stu[i].program);
printf("what would you like to update: ");
printf("ID firstname lastname date ofbirth phone number program infomation: ");
scanf("%d%d%d%d%d%d",&idu,&firstu,&lastu,&dobu,&phoneu,&programu);
if(idu=1,idu<11,idu++)
{
printf("enter new ID number for student: ");
scanf("%d",&newid);
}
}
return i;
}
int search(struct SMS stu[],int n)
{ int i,m;
printf("Enter id to search: ");
scanf("%d",&m);
for(i=0;i<n;i++)
if(m==stu[i].id)
return i;
return i;
}
void print(struct SMS stu[],int n)
{ int i;
printf("id first last dob phone program of study ");
for(i=0;i<n;i++)
printf("%d %s %s %s %s %s ",stu[i].id,stu[i].first,stu[i].last,stu[i].dob,
stu[i].phone,stu[i].program);
}
void printstudent(struct SMS stu[],int n,int i)
{
printf("id first last dob phone program of study ");
printf("%d %s %s %s %s %s ",stu[i].id,stu[i].first,stu[i].last,stu[i].dob,
stu[i].phone,stu[i].program);
}
Explanation / Answer
x.Xlor="red">please rate - thanks now updates, and prints to file when you quit #include #include struct SMS {int id; char first[15]; char last[15]; char dob[11]; char phone[15]; char program[20]; }stu[10]; int create(struct SMS[],int); int search(struct SMS[],int ); void update(struct SMS[],int); void save(struct SMS[],int); void print(struct SMS[],int); void printstudent(struct SMS[],int,int); int menu(); int main() {int choice,n=0,m; for(;;) { choice=menu(); switch (choice) {case 1: n=create(stu,n);break; case 2:update(stu,n);break; case 3: m=search(stu,n); if(m>=n) printf("student not in data base "); else printstudent(stu,n,m); break; case 4: print(stu,n);break; case 5: save(stu,n); return 0; } } getch(); return 0; } int menu() {int choice; printf(" *~*~*~*WeLcome To Dwayne Brown's And Mohit Belani's Program*~*~*~* "); printf("What would you like to do to the database? "); printf("1. Create 2. Update 3. Search 4. Print 5. Quit Enter choice: "); scanf("%d",&choice); while(choice5) {printf("Invalid entry "); printf("What would you like to do to the database? "); printf("1. create 2. update 3. search 4. print 5. Quit Enter choice: "); scanf("%d",&choice); } return choice; } void save(struct SMS stu[],int n) {FILE *out; out = fopen("studentrecords.txt","w"); int i; for(i=0;i0) { printf("Enter last name: "); scanf("%s",&stu[i].last); printf("Enter first name: "); scanf("%s",&stu[i].first); printf("Enter date of birth (mm/dd/yyyy): "); scanf("%s",&stu[i].dob); printf("Enter phone number ((xxx)-xxx-xxxx): "); scanf("%s",&stu[i].phone); printf("Enter program of study: "); scanf("%s",&stu[i].program); i++; printf(" Record of Student Saved. "); printf(" You May Continue to Enter a another student record or exit with (Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.