Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- ///teacher structure
- typedef struct teacher
- {
- char name[15], id[15], room[5], sub[10];///room means class
- float salary;
- struct teacher *next;
- }teach;
- ///student structure
- typedef struct student{
- char name[15], id[15], sec[2], Class[5];
- float fees;
- struct student *next;
- }stu;
- ///globally decleared varriables
- teach *headT = NULL;
- teach *tempT = NULL;
- teach *prevT = NULL;
- stu *headS = NULL;
- stu *tempS = NULL;
- stu *prevS = NULL;
- int i = 0, countT = 0, countS = 0;
- ///every code has to be below
- ///entry area
- //teachers data entry
- void entryTeacher(){
- int n;
- printf("How many Teachers data you want to enter:");
- scanf("%d", &n);
- for(i = 0; i < n; i++){
- teach *newNode;
- printf("\nEnter data for #%d no Teacher\n",++countT);
- newNode = (teach*)malloc(sizeof(teach));
- printf("\tEnter Teacher Name:");
- scanf("%s", &newNode-> name);
- printf("\tEnter Teachers ID:");
- scanf("%s", &newNode-> id);
- printf("\tEnter Subject:");
- scanf("%s", &newNode-> sub);
- printf("\tEnter Room NO:");
- scanf("%s", &newNode-> room);
- printf("\tEnter salary:");
- scanf("%f", &newNode-> salary);
- newNode-> next = NULL;
- if(headT == NULL){
- headT = newNode;
- }
- else{
- tempT = headT;
- while(tempT-> next != NULL)
- tempT = tempT-> next;
- tempT-> next = newNode;
- }
- }
- }//teachers data ends here
- //students data entry
- void entryStudent(){
- int n;
- printf("How many Students data you want to enter:");
- scanf("%d", &n);
- for(i = 0; i < n; i++){
- stu *newNode;
- printf("\nEnter data for #%d no Student\n",++countS);
- newNode = (stu*)malloc(sizeof(stu));
- printf("\tEnter Student Name:");
- scanf("%s", &newNode-> name);
- printf("\tEnter student ID:");
- scanf("%s", &newNode-> id);
- printf("\tEnter Section:");
- scanf("%s", &newNode-> sec);
- printf("\tEnter Class NO:");
- scanf("%s", &newNode-> Class);
- printf("\tEnter Fees:");
- scanf("%f", &newNode-> fees);
- newNode-> next = NULL;
- if(headS == NULL){
- headS = newNode;
- }
- else{
- tempS = headS;
- while(tempS-> next != NULL)
- tempS = tempS-> next;
- tempS-> next = newNode;
- }
- }
- }
- //STUDENTS DATA ends here
- ///printing area
- //print teachers info
- void printTeacher(){
- printf("\n\t\tDisplay Teachers Information\n");
- tempT = headT;
- printf("Total %d Teachers Data\n", countT);
- while(tempT != NULL){
- printf("\tTeachers ID: %s\n", tempT-> id);
- printf("\tTeachers Name: %s\n", tempT-> name);
- printf("\tAssigned Subject: %s\n", tempT-> sub);
- printf("\tAssigned Room NO: %s\n", tempT-> room);
- printf("\tMonthly Salary: %.2f\n\n", tempT-> salary);
- tempT=tempT->next;
- }
- }
- //student information display area
- void printStudent(){
- printf("\n\t\tDisplay Students Information\n");
- tempS =headS;
- printf("Total %d Students Data\n",countS);
- while(tempS!=NULL)
- {
- printf("\tStudent ID: %s\n",tempS->id);
- printf("\tStudent Name: %s\n",tempS->name);
- printf("\tStudent Section: %s\n",tempS->sec);
- printf("\tStudent Class: %s\n",tempS->Class);
- printf("\tStudent Fees: %.2f\n\n",tempS->fees);
- tempS=tempS->next;
- }
- }
- ///Printing Area ends...!
- ///searching area
- //teachers search code starts here
- void searchT(){
- tempT = headT;
- char value[15];
- printf("Enter The Data You Want To search(Name Or ID Or Subject Or Room NO\n");
- printf("\tPlease Enter Your Required Data:");
- scanf("%s", &value);
- while(tempT-> next != NULL && ((strcmp(tempT-> name, value)) && (strcmp(tempT-> id, value)) && (strcmp(tempT-> sub, value)) && (strcmp(tempT-> room, value)) && (strcmp(tempT-> room, value)) ) != 0 )
- tempT = tempT-> next;
- if(tempT == NULL)
- printf("SORRY...! Data Not Found");
- else{
- printf("\nData Found Your Data Should Be below here\n");
- printf("\tTeachers ID: %s\n", tempT-> id);
- printf("\tTeachers Name: %s\n", tempT-> name);
- printf("\tAssigned Subject: %s\n", tempT-> sub);
- printf("\tAssigned Room NO: %s\n", tempT-> room);
- printf("\tMonthly Salary: %.2f\n\n", tempT-> salary);
- }
- }
- //Teachers search code ends here
- //students search code starts here
- void searchsS(){
- tempS = headS;
- char value[15];
- printf("Enter The Data You Want To search(Name Or ID Or Section Or Class NO\n");
- printf("\tPlease Enter Your Required Data:");
- scanf("%s", &value);
- while(tempS-> next != NULL && ((strcmp(tempS-> name, value)) && (strcmp(tempS-> id, value)) && (strcmp(tempS-> sec, value)) && (strcmp(tempS-> Class, value)) != 0 ))
- tempS = tempS-> next;
- if(tempS == NULL)
- printf("SORRY...! Data Not Found");
- else{
- printf("\nData Found Your Data Should Be below here\n");
- printf("\tStudent ID: %s\n",tempS->id);
- printf("\tStudent Name: %s\n",tempS->name);
- printf("\tStudent Section: %s\n",tempS->sec);
- printf("\tStudent Class: %s\n",tempS->Class);
- printf("\tStudent Fees: %.2f\n\n",tempS->fees);
- }
- }
- //students search code ends here
- ///deleting area
- //teachers data delete
- void deleteT(){
- tempT = headT;
- char value[15];
- printf("Enter The Data You Want To Delete(Name Or ID Or Subject Or Room NO\n");
- scanf("%s", &value);
- while(tempT-> next != NULL && ((strcmp(tempT-> name, value) != 0) && (strcmp(tempT-> id, value) != 0) && (strcmp(tempT-> sub, value) != 0) && (strcmp(tempT-> room, value) != 0) && (strcmp(tempT-> room, value) != 0) ) != 0 ){
- prevT = tempT;
- tempT= tempT-> next;
- }
- if(tempT == NULL)
- printf("Sorry Data not found\n");
- else {
- if(tempT == headT){
- headT = headT-> next;
- free(tempT);
- }
- else{
- prevT-> next = tempT-> next;
- free(tempT);
- }
- printf("Delete Successful\n");
- }
- }
- //teachers data delete ends here
- //students data delete
- void deleteS(){
- tempS = headS;
- char value[15];
- printf("Enter The Data You Want To Delete(Name Or ID Or Subject Or Room NO\n");
- scanf("%s", &value);
- while(tempS-> next != NULL && ((strcmp(tempS-> name, value) != 0) && (strcmp(tempS-> id, value) != 0) && (strcmp(tempS-> sec, value) != 0) && (strcmp(tempS-> Class, value) != 0) ) != 0 ){
- prevS = tempS;
- tempS= tempS-> next;
- }
- if(tempS == NULL)
- printf("Sorry Data not found\n");
- else {
- if(tempS == headS){
- headS = headS-> next;
- free(tempS);
- }
- else{
- prevS-> next = tempS-> next;
- free(tempS);
- }
- printf("Delete Successful\n");
- }
- }
- //students data delete ends here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement