Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <windows.h>
- #include <conio.h>
- struct student
- {
- int id;
- int cla;
- long int p_num;
- char group[20];
- char name[20];
- char gender[20];
- double bangla,english,math,physics,chemistry,biology;
- struct student *next,*prev;
- }*start=NULL,*end=NULL,*current;
- void create()
- {
- if(start==NULL && end==NULL)
- {
- struct student *new_node;
- new_node=(struct student*)malloc(1*sizeof(struct student));
- printf("Enter Name: ");
- scanf("%s",&new_node->name);
- printf("\nEnter Gender: ");
- scanf("%s",&new_node->gender);
- printf("\nEnter Class: ");
- scanf("%d",&new_node->cla);
- printf("\nEnter ID: ");
- scanf("%d",&new_node->id);
- printf("\nEnter Group: ");
- scanf("%s",&new_node->group);
- printf("\nEnter Parents Phone Number: ");
- scanf("%ld",&new_node->p_num);
- new_node->next=NULL;
- new_node->prev=NULL;
- start=new_node;
- end=new_node;
- current=new_node;
- system("cls");
- }
- else
- {
- struct student *new_node;
- new_node=(struct student*)malloc(1*sizeof(struct student));
- printf("Enter Name: ");
- scanf("%s",&new_node->name);
- printf("\nEnter Class: ");
- printf("\nEnter Gender: ");
- scanf("%s",&new_node->gender);
- scanf("%d",&new_node->cla);
- printf("\nEnter ID: ");
- scanf("%d",&new_node->id);
- printf("\nEnter Group: ");
- scanf("%s",&new_node->group);
- printf("\nEnter Parents Phone Number: ");
- scanf("%ld",&new_node->p_num);
- new_node->next=NULL;
- new_node->prev=NULL;
- current->next=new_node;
- new_node->prev=current;
- end=new_node;
- current=new_node;
- system("cls");
- }
- }
- void dis()
- {
- struct student *c;
- c=start;
- while(c!=NULL)
- {
- printf("Name : %s Gender : %s\nClass : %d ID : %d\nGroup : %s Parents Phone Number: %ld\n",c->name,c->gender,c->cla,c->id,c->group,c->p_num);
- c=c->next;
- }
- }
- struct teacher
- {
- int id;
- char name[20];
- char gender[20];
- char group[20];
- long int phnum;
- struct teacher *next,*prev;
- }*start1=NULL,*end1=NULL,*current1;
- void create1()
- {
- struct teacher *new_node;
- if(start1==NULL && end1==NULL)
- {
- new_node=(struct teacher*)malloc(1*sizeof(struct teacher));
- printf("\nEnter the number of teacher id:\n");
- scanf("%d",&new_node->id);
- printf("\nEnter your group:\n");
- scanf("%s",&new_node->group);
- printf("\nEnter the teacher name:\n");
- scanf("%s",&new_node->name);
- printf("\nEnter the teacher gender:\n");
- scanf("%s",&new_node->gender);
- printf("\nEnter the teacher phone number:\n");
- scanf("%ld",&new_node->phnum);
- new_node->next=NULL;
- new_node->prev=NULL;
- start1=new_node;
- end1=new_node;
- current1=new_node;
- system("cls");
- }
- else
- {
- new_node=(struct teacher*)malloc(1*sizeof(struct teacher));
- printf("\nEnter Teacher ID:\n");
- scanf("%d",&new_node->id);
- printf("\nEnter Teacher Group:\n");
- scanf("%s",&new_node->group);
- printf("\nEnter the teacher name:\n");
- scanf("%s",&new_node->name);
- printf("\nEnter the teacher gender:\n");
- scanf("%s",&new_node->gender);
- printf("\nEnter the teacher phone number:\n");
- scanf("%ld",&new_node->phnum);
- new_node->next=NULL;
- new_node->prev=NULL;
- current1->next=new_node;
- new_node->prev=current1;
- current1=new_node;
- end1=new_node;
- system("cls");
- }
- }
- int search(int a,int y)
- {
- struct student *c;
- struct teacher *c1;
- int po=0;
- if(a!=0 && y!=0)
- {
- c=start;
- while(c!=NULL)
- {
- po++;
- if(c->cla==a && c->id)
- {
- return po;
- }
- c=c->next;
- }
- return -1;
- }
- else
- {
- c1=start1;
- while(c1!=NULL)
- {
- po++;
- if(c1->id==a)
- {
- return po;
- }
- c1=c1->next;
- }
- return -1;
- }
- }
- void dis1()
- {
- struct teacher *c;
- c=start1;
- while(c!=NULL)
- {
- printf("\nTeacher ID:%d\n",c->id);
- printf("Your group:%s\n",c->group);
- printf("Teacher Name:%s\n",c->name);
- printf("Teacher Gender:%s\n",c->gender);
- printf("Teacher Phone number:%ld\n",c->phnum);
- c=c->next;
- }
- }
- void result()
- {
- int cls,id;
- printf("\nEnter Class and ID NO:\n");
- scanf("%d %d",&cls,&id);
- struct student *n,*c;
- c=start;
- int po=0;
- while(c!=NULL)
- {
- po++;
- if(c->cla==cls && c->id==id)
- {
- break;
- }
- c=c->next;
- }
- }
- int main()
- {
- int x,y;
- while(1)
- {
- printf("1.Enter Student Details.\n2.View All Student Details\n3.Search Student Details.\n");
- printf("4.Enter Teacher Details.\n5.View All Teacher Details\n6.Search Teacher Details.\n");
- scanf("%d",&x);
- switch(x)
- {
- case 1:
- {
- while(1)
- {
- system("cls");
- create();
- printf("Do you want to continue?\n");
- printf("1.Yes 2.No\n");
- int e;
- scanf("%d",&e);
- if(e==1) continue;
- else break;
- }
- system("cls");
- break;
- }
- case 2:
- {
- system("cls");
- dis();
- printf("Press any key to quit.");
- getch();
- system("cls");
- break;
- }
- case 3:
- {
- while(1)
- {
- system("cls");
- int x1,y1;
- printf("Enter Class: ");
- scanf("%d",&x1);
- printf("\nEnter Student ID: ");
- scanf("%d",&y1);
- system("cls");
- int pos = search(x1,y1);
- if(pos==-1)
- {
- printf("Not Found");
- getch();
- system("cls");
- }
- else
- {
- struct student *b;
- b=start;
- int j;
- for(j=0; j<pos-1; j++)
- {
- b=b->next;
- }
- printf("Name : %s\nGender : %s\nClass : %d\nID : %d\nGroup : %s\nParents Number : %ld\n",b->name,b->gender,b->cla,b->id,b->group,b->p_num);
- printf("Press any key.");
- getch();
- system("cls");
- }
- printf("Do you want to search another?\n 1.Yes 2.No\n");
- int e;
- scanf("%d",&e);
- if(e==1) continue;
- else if(e==2) break;
- }
- system("cls");
- break;
- }
- case 4:
- {
- while(1)
- {
- system("cls");
- create1();
- int e;
- printf("Do you want to Continue?\n1.Yes 2.No\n");
- scanf("%d",&e);
- if(e==1) continue;
- else if(e==2) break;
- }
- system("cls");
- break;
- }
- case 5:
- {
- dis1();
- getch();
- system("cls");
- break;
- }
- case 6:
- {
- printf("Enter Id:\n");
- int k;
- scanf("%d",&k);
- int pos1 = search(k,0);
- if(pos1==-1)
- {
- printf("\n Not Found\n");
- }
- else
- {
- struct teacher *c;
- c=start1;
- int j;
- for(j=0; j<pos1-1; j++)
- {
- c=c->next;
- }
- printf("\nTeacher ID:%d\n",c->id);
- printf("Your group:%s\n",c->group);
- printf("Teacher Name:%s\n",c->name);
- printf("Teacher Gender:%s\n",c->gender);
- printf("Teacher Phone number:%ld\n",c->phnum);
- getch();
- system("cls");
- }
- break;
- }
- case 7:
- {
- int x1,y1;
- printf("Enter Class: ");
- scanf("%d",&x1);
- printf("Enter Student ID: ");
- scanf("%d",&y1);
- int k;
- //y=2;
- int pos1 = search(x1,y1);
- if(pos1==-1)
- {
- printf("\n Not Found\n");
- }
- else
- {
- struct student *c;
- c=start;
- int j;
- for(j=0; j<pos1-1; j++)
- {
- c=c->next;
- }
- printf("Bangla :\n");
- scanf("%lf",&c->bangla);
- printf("English:\n");
- scanf("%lf",&c->english);
- printf("Math:\n");
- scanf("%lf",&c->math);
- printf("Physics:\n");
- scanf("%lf",&c->physics);
- printf("Chemistry:\n");
- scanf("%lf",&c->chemistry);
- printf("Biology:\n");
- scanf("%lf",&c->biology);
- //getch();
- system("cls");
- }
- break;
- }
- case 8:
- {
- int x1,y1;
- printf("Enter Class: ");
- scanf("%d",&x1);
- printf("Enter Student ID: ");
- scanf("%d",&y1);
- int k;
- //y=2;
- int pos1 = search(x1,y1);
- if(pos1==-1)
- {
- printf("\n Not Found\n");
- }
- else
- {
- struct student *c;
- c=start;
- int j;
- for(j=0; j<pos1-1; j++)
- {
- c=c->next;
- }
- printf("Bangla : %.2lf\n",c->bangla);
- //scanf("%lf",&c->bangla);
- printf("English: %.2lf\n",c->english);
- //scanf("%lf",&c->english);
- printf("Math: %.2lf\n",c->math);
- //scanf("%lf",&c->math);
- printf("Physics: %.2lf\n",c->physics);
- //scanf("%lf",&c->physics);
- printf("Chemistry: %.2lf\n",c->chemistry);
- //scanf("%lf",&c->chemistry);
- printf("Biology: %.2lf\n",c->biology);
- //scanf("%lf",c->biology);
- getch();
- system("cls");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement