Advertisement
mustahidhasan

only functions

Jul 22nd, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 7.15 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4.  
  5. ///teacher structure
  6. typedef struct teacher
  7. {
  8.     char name[15], id[15], room[5], sub[10];///room means class
  9.     float salary;
  10.  
  11.     struct teacher *next;
  12.  
  13. }teach;
  14.  
  15.  
  16. ///student structure
  17. typedef struct student{
  18.     char name[15], id[15], sec[2], Class[5];
  19.     float fees;
  20.  
  21.     struct student *next;
  22. }stu;
  23.  
  24.  
  25. ///globally decleared varriables
  26. teach *headT = NULL;
  27. teach *tempT = NULL;
  28. teach *prevT = NULL;
  29.  
  30. stu *headS = NULL;
  31. stu *tempS = NULL;
  32. stu *prevS = NULL;
  33. int i = 0, countT = 0, countS = 0;
  34. ///every code has to be below
  35.  
  36. ///entry area
  37. //teachers data entry
  38. void entryTeacher(){
  39.     int n;
  40.     printf("How many Teachers data you want to enter:");
  41.     scanf("%d", &n);
  42.  
  43.     for(i = 0; i < n; i++){
  44.        teach *newNode;
  45.        printf("\nEnter data for #%d no Teacher\n",++countT);
  46.        newNode = (teach*)malloc(sizeof(teach));
  47.        printf("\tEnter Teacher Name:");
  48.        scanf("%s", &newNode-> name);
  49.        printf("\tEnter Teachers ID:");
  50.        scanf("%s", &newNode-> id);
  51.        printf("\tEnter Subject:");
  52.        scanf("%s", &newNode-> sub);
  53.        printf("\tEnter Room NO:");
  54.        scanf("%s", &newNode-> room);
  55.        printf("\tEnter salary:");
  56.        scanf("%f", &newNode-> salary);
  57.        newNode-> next = NULL;
  58.  
  59.        if(headT == NULL){
  60.         headT = newNode;
  61.        }
  62.        else{
  63.         tempT = headT;
  64.         while(tempT-> next != NULL)
  65.             tempT = tempT-> next;
  66.         tempT-> next = newNode;
  67.        }
  68.     }
  69. }//teachers data ends here
  70.  
  71. //students data entry
  72. void entryStudent(){
  73.     int n;
  74.     printf("How many Students data you want to enter:");
  75.     scanf("%d", &n);
  76.  
  77.     for(i = 0; i < n; i++){
  78.        stu *newNode;
  79.        printf("\nEnter data for #%d no Student\n",++countS);
  80.        newNode = (stu*)malloc(sizeof(stu));
  81.        printf("\tEnter Student Name:");
  82.        scanf("%s", &newNode-> name);
  83.        printf("\tEnter student ID:");
  84.        scanf("%s", &newNode-> id);
  85.        printf("\tEnter Section:");
  86.        scanf("%s", &newNode-> sec);
  87.        printf("\tEnter Class NO:");
  88.        scanf("%s", &newNode-> Class);
  89.        printf("\tEnter Fees:");
  90.        scanf("%f", &newNode-> fees);
  91.  
  92.        newNode-> next = NULL;
  93.  
  94.        if(headS == NULL){
  95.         headS = newNode;
  96.        }
  97.        else{
  98.         tempS = headS;
  99.         while(tempS-> next != NULL)
  100.             tempS = tempS-> next;
  101.         tempS-> next = newNode;
  102.        }
  103.     }
  104. }
  105. //STUDENTS DATA ends here
  106. ///printing area
  107. //print teachers info
  108. void printTeacher(){
  109.     printf("\n\t\tDisplay Teachers Information\n");
  110.     tempT = headT;
  111.     printf("Total %d Teachers Data\n", countT);
  112.     while(tempT != NULL){
  113.         printf("\tTeachers ID: %s\n", tempT-> id);
  114.         printf("\tTeachers Name: %s\n", tempT-> name);
  115.         printf("\tAssigned Subject: %s\n", tempT-> sub);
  116.         printf("\tAssigned Room NO: %s\n", tempT-> room);
  117.         printf("\tMonthly Salary: %.2f\n\n", tempT-> salary);
  118.         tempT=tempT->next;
  119.     }
  120. }
  121. //student information display area
  122. void printStudent(){
  123.     printf("\n\t\tDisplay Students Information\n");
  124.     tempS =headS;
  125.     printf("Total %d Students Data\n",countS);
  126.     while(tempS!=NULL)
  127.     {
  128.         printf("\tStudent ID: %s\n",tempS->id);
  129.         printf("\tStudent Name: %s\n",tempS->name);
  130.         printf("\tStudent Section: %s\n",tempS->sec);
  131.         printf("\tStudent Class: %s\n",tempS->Class);
  132.         printf("\tStudent Fees: %.2f\n\n",tempS->fees);
  133.         tempS=tempS->next;
  134.     }
  135.  
  136. }
  137. ///Printing Area ends...!
  138. ///searching area
  139. //teachers search code starts here
  140. void searchT(){
  141.     tempT = headT;
  142.     char value[15];
  143.     printf("Enter The Data You Want To search(Name Or ID Or Subject Or Room NO\n");
  144.     printf("\tPlease Enter Your Required Data:");
  145.     scanf("%s", &value);
  146.  
  147.     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 )
  148.         tempT = tempT-> next;
  149.  
  150.         if(tempT == NULL)
  151.             printf("SORRY...! Data Not Found");
  152.         else{
  153.             printf("\nData Found Your Data Should Be below here\n");
  154.             printf("\tTeachers ID: %s\n", tempT-> id);
  155.             printf("\tTeachers Name: %s\n", tempT-> name);
  156.             printf("\tAssigned Subject: %s\n", tempT-> sub);
  157.             printf("\tAssigned Room NO: %s\n", tempT-> room);
  158.             printf("\tMonthly Salary: %.2f\n\n", tempT-> salary);
  159.  
  160.  
  161.     }
  162. }
  163. //Teachers search code ends here
  164.  
  165. //students search code starts here
  166. void searchsS(){
  167.     tempS = headS;
  168.     char value[15];
  169.     printf("Enter The Data You Want To search(Name Or ID Or Section Or Class NO\n");
  170.     printf("\tPlease Enter Your Required Data:");
  171.     scanf("%s", &value);
  172.  
  173.     while(tempS-> next != NULL && ((strcmp(tempS-> name, value)) && (strcmp(tempS-> id, value)) && (strcmp(tempS-> sec, value)) && (strcmp(tempS-> Class, value)) != 0 ))
  174.         tempS = tempS-> next;
  175.  
  176.         if(tempS == NULL)
  177.             printf("SORRY...! Data Not Found");
  178.         else{
  179.             printf("\nData Found Your Data Should Be below here\n");
  180.             printf("\tStudent ID: %s\n",tempS->id);
  181.             printf("\tStudent Name: %s\n",tempS->name);
  182.             printf("\tStudent Section: %s\n",tempS->sec);
  183.             printf("\tStudent Class: %s\n",tempS->Class);
  184.             printf("\tStudent Fees: %.2f\n\n",tempS->fees);
  185.         }
  186.  
  187. }
  188.  
  189. //students search code ends here
  190. ///deleting area
  191. //teachers data delete
  192. void deleteT(){
  193.     tempT = headT;
  194.     char value[15];
  195.  
  196.     printf("Enter The Data You Want To Delete(Name Or ID Or Subject Or Room NO\n");
  197.     scanf("%s", &value);
  198.     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 ){
  199.         prevT = tempT;
  200.         tempT= tempT-> next;
  201.     }
  202.     if(tempT == NULL)
  203.         printf("Sorry Data not found\n");
  204.     else {
  205.         if(tempT == headT){
  206.             headT = headT-> next;
  207.             free(tempT);
  208.         }
  209.         else{
  210.             prevT-> next = tempT-> next;
  211.             free(tempT);
  212.         }
  213.         printf("Delete Successful\n");
  214.  
  215.     }
  216.  
  217. }
  218. //teachers data delete ends here
  219.  
  220.  
  221. //students data delete
  222. void deleteS(){
  223.     tempS = headS;
  224.     char value[15];
  225.  
  226.     printf("Enter The Data You Want To Delete(Name Or ID Or Subject Or Room NO\n");
  227.     scanf("%s", &value);
  228.     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 ){
  229.         prevS = tempS;
  230.         tempS= tempS-> next;
  231.     }
  232.     if(tempS == NULL)
  233.         printf("Sorry Data not found\n");
  234.     else {
  235.         if(tempS == headS){
  236.             headS = headS-> next;
  237.             free(tempS);
  238.         }
  239.         else{
  240.             prevS-> next = tempS-> next;
  241.             free(tempS);
  242.         }
  243.         printf("Delete Successful\n");
  244.  
  245.     }
  246.  
  247. }
  248. //students data delete ends here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement