Advertisement
Guest User

aita dak

a guest
Dec 12th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.39 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h >
  3. #include<string.h>
  4. typedef struct node
  5. {
  6. char name[20];
  7. char id[20];
  8. char dept[70];
  9. char designation[50];
  10. char phone[11];
  11. int batch;
  12. char sec[5];
  13. char blood[3];
  14. struct node *left,*right;
  15.  
  16. }node;
  17.  
  18.  
  19. node *root_teacher=NULL,*root_student=NULL,*root_staff=NULL,*root_cr=NULL;
  20. int flag=0,ft=0,fs=0,fst=0,fds=0;
  21.  
  22.  
  23. void Delete() ;
  24. void deletet();
  25. void searchcr();
  26. void search() ;
  27. void bst(); //flag using search cr
  28. //ft using teacher display
  29. //fs using student display
  30. //fds for same department and same batch
  31. //fst using staff display
  32.  
  33.  
  34. void bst(node *head,node *temp) //bst for teacher
  35. {
  36. if(strcmp(head->id,temp->id)==1||strcmp(head->id,temp->id)==0)
  37. {
  38. if(head->left==NULL)
  39. {
  40. head->left=temp;
  41. return;
  42. }
  43. else
  44. {
  45. bst(head->left,temp);
  46. }
  47. }
  48. else if(strcmp(head->id,temp->id)==-1)
  49. {
  50. if(head->right==NULL)
  51. {
  52. head->right=temp;
  53. return;
  54. }
  55. else
  56. {
  57. bst(head->right,temp);
  58. }
  59. }
  60. }
  61.  
  62.  
  63. node *getSuccessor(node *n) // for teacher
  64. {
  65. if(n->left == NULL)
  66. {
  67. return n;
  68. }
  69. else
  70. {
  71. getSuccessor(n->left);
  72. }
  73. }
  74. node *parent(node *n , node *r) //for teacher
  75. {
  76. // we alredy checked that n is not the root and n is exist
  77. if(strcmp(r->id,n->id)==1||strcmp(r->id,n->id)==0)
  78. {
  79. if(strcmp(r->left->id,n->id)==0)
  80. {
  81. return r;
  82. }
  83. else
  84. {
  85. parent(n , r->left);
  86. }
  87. }
  88. else
  89. {
  90. if(strcmp(r->right->id,n->id)==0)
  91. {
  92. return r;
  93. }
  94. else
  95. {
  96. parent(n , r->right);
  97. }
  98. }
  99.  
  100. }
  101. void deletet(node *n) // for teacher
  102. {
  103. char x[50];
  104. node *successor, *p;
  105. if(n->left != NULL && n->right != NULL)
  106. {
  107. successor = getSuccessor(n->right);
  108. strcpy(x,successor->id);
  109. deletet(successor);
  110. strcpy(n->id,x);
  111. return;
  112. }
  113.  
  114. if(n->left == NULL && n->right == NULL)
  115. {
  116.  
  117. if(n == root_teacher)
  118. {
  119. root_teacher = NULL;
  120. }
  121. else
  122. {
  123. p = parent(n , root_teacher);
  124. if(p->left == n)
  125. {
  126. p->left = NULL;
  127. }
  128. else
  129. {
  130. p->right = NULL;
  131. }
  132.  
  133. }
  134. free(n);
  135. return;
  136. }
  137. if(n->left != NULL && n->right == NULL)
  138. {
  139. strcpy(x,n->left->id);
  140. deletet(n->left);
  141. strcpy(n->id,x);
  142. return;
  143. }
  144. if(n->left == NULL && n->right != NULL)
  145. {
  146. strcpy(x,n->right->id);
  147. deletet(n->right);
  148. strcpy(n->id,x);
  149. return;
  150. }
  151.  
  152. }
  153. void searchcr(node *head,char s[],int b) //searcht=searching for teacher
  154. {
  155. if(head==NULL)
  156. {
  157. return;
  158. }
  159.  
  160.  
  161. searchcr(head->left,s,b);
  162. if(strcmp(head->sec,s)==0&&head->batch==b)
  163. {
  164. printf("\nName Of the Department:%s\n",head->dept);
  165. printf("Batch:%d\n",head->batch);
  166.  
  167. printf("Name:%s\n",head->name);
  168.  
  169. printf("Student ID:%s\n",head->id);
  170. printf("Section:%s\n",head->sec);
  171.  
  172. printf("Phone No:%s\n",head->phone);
  173.  
  174. printf("Blood Group:%s\n",head->blood);
  175. flag=1;
  176. }
  177.  
  178.  
  179. searchcr(head->right,s,b);
  180. return;
  181.  
  182. }
  183.  
  184.  
  185. node *searcht(node *head,char s[]) //searcht=searching for teacher
  186. {
  187. if(head==NULL)
  188. {
  189. return NULL;
  190. }
  191. else if(strcmp(head->id,s)==0)
  192. {
  193. return head;
  194. }
  195. else if(strcmp(head->id,s)==1)
  196. {
  197. searcht(head->left,s);
  198.  
  199. }
  200. else if(strcmp(head->id,s)==-1)
  201. {
  202. searcht(head->right, s);
  203. }
  204. }
  205. void Delete()
  206. {
  207. printf("\n1.Delete Teacher's Information\n");
  208. printf("2.Delete Student's Information\n");
  209. printf("3.Delete Staff Information\n");
  210. printf("4.Delete CR Information\n");
  211. printf("5.Menu\n");
  212. printf("6.Exit\n");
  213. int x;
  214. printf("Choose Any one:");
  215. scanf("%d",&x);
  216. switch(x)
  217. {
  218. case 1:
  219. { char temp[50];
  220. printf("Enter Teacher's Id:");
  221. scanf(" %[^\n]",temp);
  222. if(root_teacher==NULL)
  223. {
  224. printf("\nNO Information Available\n");
  225. }
  226. else
  227. {
  228. node *n1=searcht(root_teacher,temp);
  229. if(n1==NULL)
  230. {
  231. printf("NO Information Available!!\n\n");
  232. }
  233.  
  234.  
  235. else
  236. {
  237. deletet(n1);
  238. printf("\nInformation Deleted!!\n\n");
  239. }
  240.  
  241. }
  242. printf("1.Back\n");
  243. printf("2.Menu\n");
  244. int z;
  245. printf("choose One:");
  246. scanf("%d",&z);
  247. if(z==1)
  248. {
  249. Delete();
  250. }
  251. else
  252. {
  253. menu();
  254. }
  255. }
  256. case 2:
  257. {
  258. char temp[50];
  259. printf("Enter Student Id:");
  260. scanf("%s",temp);
  261. if(root_student==NULL)
  262. {
  263. printf("\nNO Information Available\n");
  264. }
  265.  
  266. else
  267. {
  268.  
  269.  
  270. node *n2=searcht(root_student,temp);
  271. if(n2==NULL)
  272. {
  273. printf("NO Information Available!!\n\n");
  274. }
  275. else
  276. {
  277. deletet(n2);
  278. printf("\nInformation Deleted!!\n\n");
  279. }
  280.  
  281. }
  282. printf("1.Back\n");
  283. printf("2.Menu\n");
  284. int z;
  285. printf("choose One:");
  286. scanf("%d",&z);
  287. if(z==1)
  288. {
  289. Delete();
  290. }
  291. else
  292. {
  293. menu();
  294. }
  295. }
  296. case 3:
  297. {
  298. char temp[50];
  299. printf("Enter Staff Id:");
  300. scanf(" %[^\n]",temp);
  301. if(root_staff==NULL)
  302. {
  303. printf("\nNO Information Available\n");
  304. }
  305.  
  306. else
  307. {
  308.  
  309.  
  310. node *n1=searcht(root_staff,temp);
  311. if(n1==NULL)
  312. {
  313. printf("NO Information Available!!\n\n");
  314. }
  315. else
  316. {
  317. deletet(n1);
  318. printf("\nInformation Deleted!!\n\n");
  319. }
  320.  
  321. }
  322. printf("1.Back\n");
  323. printf("2.Menu\n");
  324. int z;
  325. printf("choose One:");
  326. scanf("%d",&z);
  327. if(z==1)
  328. {
  329. Delete();
  330. }
  331. else
  332. {
  333. menu();
  334. }
  335. }
  336. case 4:
  337. {
  338. char temp[50];
  339. printf("Enter CR Id:");
  340. scanf(" %[^\n]",temp);
  341. if(root_cr==NULL)
  342. {
  343. printf("\nNO Information Available\n");
  344. }
  345.  
  346. else
  347. {
  348.  
  349.  
  350. node *n1=searcht(root_cr,temp);
  351. if(n1==NULL)
  352. {
  353. printf("NO Information Available!!\n\n");
  354. }
  355. else
  356. {
  357. deletet(n1);
  358. printf("\nInformation Deleted!!\n\n");
  359. }
  360.  
  361. }
  362. printf("1.Back\n");
  363. printf("2.Menu\n");
  364. int z;
  365. printf("choose One:");
  366. scanf("%d",&z);
  367. if(z==1)
  368. {
  369. Delete();
  370. }
  371. else
  372. {
  373. menu();
  374. }
  375. }
  376. case 5:
  377. {
  378. menu();
  379. break;
  380. }
  381. case 6:
  382. {
  383. exit(0);
  384. break;
  385. }
  386. }
  387. }
  388.  
  389.  
  390.  
  391. void search()
  392. {
  393. printf("\n1.Search Techer's Information\n");
  394. printf("2.Search Student's Information\n");
  395. printf("3.Search Staff Information\n");
  396. printf("4.Search CR Information\n");
  397. printf("5.Menu\n");
  398. printf("6.Exit\n");
  399. int x;
  400. printf("Choose Any one:");
  401. scanf("%d",&x);
  402. switch(x)
  403. {
  404. case 1:
  405. { node *n;
  406. char temp[20];
  407. printf("\nEnter Teacher's ID:");
  408. scanf("%s",temp);
  409.  
  410. n=searcht(root_teacher,temp);
  411. if(n==NULL)
  412. {
  413. printf("\nNo Information Available!!\n");
  414. }
  415. else
  416. {
  417.  
  418.  
  419. printf("\nName Of the Department:%s\n",n->dept);
  420.  
  421. printf("Teacher's Name:%s\n",n->name);
  422.  
  423. printf("Teacher's ID:%s\n",n->id);
  424.  
  425. printf("Phone No:%s\n",n->phone);
  426.  
  427. printf("Designation:%s\n\n",n->designation);
  428. }
  429. printf("1.Back\n");
  430. printf("2.Menu\n");
  431. int z;
  432. printf("Choose any One:");
  433. scanf("%d",&z);
  434. if(z==1)
  435. {
  436. search();
  437. }
  438. else
  439. {
  440. menu();
  441. }
  442.  
  443. }
  444.  
  445. case 2:
  446. {node *n;
  447. char temp[20];
  448. printf("\nEnter Student ID:");
  449. scanf("%s",temp);
  450.  
  451. n=searcht(root_student,temp);
  452. if(n==NULL)
  453. {
  454. printf("\nNo Information Available!!\n");
  455. }
  456. else
  457. {
  458.  
  459.  
  460. printf("\nName Of the Department:%s\n",n->dept);
  461. printf("Batch:%d\n",n->batch);
  462.  
  463. printf("Name:%s\n",n->name);
  464.  
  465. printf("Student ID:%s\n",n->id);
  466. printf("Section:%s\n",n->sec);
  467.  
  468. printf("Phone No:%s\n",n->phone);
  469.  
  470. printf("Blood Group:%s\n",n->blood);
  471. }
  472. printf("1.Back\n");
  473. printf("2.Menu\n");
  474. int z;
  475. printf("Choose any One:");
  476. scanf("%d",&z);
  477. if(z==1)
  478. {
  479. search();
  480. }
  481. else
  482. {
  483. menu();
  484. }
  485. }
  486.  
  487. case 3:
  488. {
  489. node *n;
  490. char temp[20];
  491. printf("\nEnter Staff ID:");
  492. scanf("%s",temp);
  493.  
  494. n=searcht(root_staff,temp);
  495. if(n==NULL)
  496. {
  497. printf("\nNo Information Available!!\n");
  498. }
  499. else
  500. {
  501.  
  502.  
  503.  
  504.  
  505. printf("Name:%s\n",n->name);
  506.  
  507. printf("Staff ID:%s\n",n->id);
  508.  
  509. printf("Phone No:%s\n",n->phone);
  510.  
  511. printf("Blood Group:%s\n",n->blood);
  512. printf("Designation:%s\n\n",n->designation);
  513. }
  514. printf("1.Back\n");
  515. printf("2.Menu\n");
  516. int z;
  517. printf("Choose any One:");
  518. scanf("%d",&z);
  519. if(z==1)
  520. {
  521. search();
  522. }
  523. else
  524. {
  525. menu();
  526. }
  527. }
  528. case 4:
  529. {
  530. node *n;
  531. int b;
  532. char temp[20];
  533. printf("\nEnter Batch:");
  534. scanf("%d",&b);
  535. printf("Enter The Section:");
  536. scanf("%s",temp);
  537.  
  538. searchcr(root_cr,temp,b);
  539. if(flag==0)
  540. {
  541. printf("\nNo Information Available!!\n");
  542. }
  543. else
  544. {
  545.  
  546. flag=0;
  547.  
  548. }
  549. printf("1.Back\n");
  550. printf("2.Menu\n");
  551. int z;
  552. printf("Choose any One:");
  553. scanf("%d",&z);
  554. if(z==1)
  555. {
  556. search();
  557. }
  558. else
  559. {
  560. menu();
  561. }
  562. }
  563.  
  564. case 5:
  565. {
  566. menu();
  567.  
  568. }
  569. case 6:
  570. {
  571. exit(0);
  572. }
  573. default:
  574. {
  575. printf("\nPlease Choose Correct Option!!\a");
  576. search();
  577. }
  578.  
  579.  
  580.  
  581. }
  582. }
  583.  
  584.  
  585.  
  586. void displayst(node *head)
  587. {
  588. if(head==NULL)
  589. {
  590. return;
  591. }
  592. displayst(head->left);
  593. printf("Name:%s\n",head->name);
  594.  
  595. printf("Staff ID:%s\n",head->id);
  596.  
  597. printf("Phone No:%s\n",head->phone);
  598.  
  599. printf("Blood Group:%s\n",head->blood);
  600. printf("Designation:%s\n\n",head->designation);
  601. displayst(head->right);
  602. return;
  603.  
  604. }
  605.  
  606.  
  607. void displaydb(node *head,int b,char s[])
  608. {
  609. if(head==NULL)
  610. {
  611. return;
  612. }
  613. displaydb(head->left,b,s);
  614. if(head->batch==b && strcmp(head->dept,s)==0)
  615. {
  616.  
  617. printf("\nName Of the Department:%s\n",head->dept);
  618. printf("Batch:%d\n",head->batch);
  619.  
  620. printf("Name:%s\n",head->name);
  621.  
  622. printf("Student ID:%s\n",head->id);
  623. printf("Section:%s\n",head->sec);
  624.  
  625. printf("Phone No:%s\n",head->phone);
  626.  
  627. printf("Blood Group:%s\n\n",head->blood);
  628. fds=1;
  629.  
  630.  
  631. }
  632. displaydb(head->right,b,s);
  633. return;
  634. }
  635.  
  636.  
  637. void displayb(node *head,int b) //display for all same batch Student
  638. {
  639. if(head==NULL)
  640. {
  641. return;
  642. }
  643. displayb(head->left,b);
  644. if(head->batch==b)
  645. {
  646.  
  647. printf("\nName Of the Department:%s\n",head->dept);
  648. printf("Batch:%d\n",head->batch);
  649.  
  650. printf("Name:%s\n",head->name);
  651.  
  652. printf("Student ID:%s\n",head->id);
  653. printf("Section:%s\n",head->sec);
  654.  
  655. printf("Phone No:%s\n",head->phone);
  656.  
  657. printf("Blood Group:%s\n\n",head->blood);
  658. fs=1;
  659.  
  660.  
  661. }
  662. displayb(head->right,b);
  663. return;
  664. }
  665.  
  666.  
  667. void displays(node *head) //display all student information
  668. {
  669. if (head==NULL)
  670. {
  671. return;
  672. }
  673. displays(head->left);
  674.  
  675. printf("\nName Of the Department:%s\n",head->dept);
  676. printf("Batch:%d\n",head->batch);
  677.  
  678. printf("Name:%s\n",head->name);
  679.  
  680. printf("Student ID:%s\n",head->id);
  681. printf("Section:%s\n",head->sec);
  682.  
  683. printf("Phone No:%s\n",head->phone);
  684.  
  685. printf("Blood Group:%s\n\n",head->blood);
  686.  
  687.  
  688. displays(head->right);
  689. return;
  690.  
  691. }
  692.  
  693.  
  694. void displayt(node *head) //display for teacher.
  695. {
  696. if(head==NULL)
  697. {
  698. return;
  699. }
  700. displayt(head->left);
  701. printf("\nName Of the Department:%s\n",head->dept);
  702.  
  703. printf("Teacher's Name:%s\n",head->name);
  704.  
  705. printf("Teacher's ID:%s\n",head->id);
  706.  
  707. printf("Phone No:%s\n",head->phone);
  708.  
  709. printf("Designation:%s\n\n",head->designation);
  710. displayt(head->right);
  711. return;
  712.  
  713.  
  714. }
  715. void displayd(node *head,char s[]) //display departmentwise for teacher
  716. {
  717. if(head==NULL)
  718. {
  719. return;
  720. }
  721. displayd(head->left,s);
  722. if(strcmp(head->dept,s)==0)
  723. {
  724. printf("\nName Of the Department:%s\n",head->dept);
  725.  
  726. printf("Teacher's Name:%s\n",head->name);
  727.  
  728. printf("Teacher's ID:%s\n",head->id);
  729.  
  730. printf("Phone No:%s\n",head->phone);
  731.  
  732. printf("Designation:%s\n\n",head->designation);
  733. ft=1;
  734. }
  735. displayd(head->right,s);
  736. return;
  737. }
  738. void display()
  739. {
  740. printf("\n1.Display Teacher Information\n");
  741. printf("2.Display Student Information\n");
  742. printf("3.display Staff Information\n");
  743. printf("4.Menu\n");
  744. printf("5.Exit\n");
  745. int x;
  746. printf("Choose Any One:");
  747. scanf("%d",&x);
  748. switch(x)
  749. {
  750. case 1:
  751. {
  752. printf("\n1.Display All Teacher Information\n");
  753. printf("2.Display Department Teacher Information\n");
  754. int d;
  755. printf("Choose One:");
  756. scanf("%d",&d);
  757. {
  758. if(d==1)
  759. {
  760. if(root_teacher==NULL)
  761. {
  762. printf("\nNo Teacher Information Available!!\n");
  763. }
  764. else
  765. {
  766. displayt(root_teacher);
  767. }
  768. }
  769. else if(d==2)
  770. {
  771.  
  772. if(root_teacher==NULL)
  773. {
  774. printf("\nNo Teacher Information Available!!\n");
  775. }
  776. else
  777. { printf("Enter Department:");
  778. char temp[70];
  779. scanf(" %[^\n]",temp);
  780. displayd(root_teacher,temp);
  781. if(ft==0)
  782. {
  783. printf("\nNo Information Available!!\n");
  784. }
  785. else
  786. {
  787. ft=0;
  788. }
  789. }
  790. }
  791. else
  792. {
  793. printf("Choose Correct Option!!!\a");
  794. display();
  795. }
  796. }
  797.  
  798. printf("\n1.Back\n");
  799. printf("\n2.Menu\n");
  800. int y;
  801. printf("Choose any One:");
  802. scanf("%d",&y);
  803. if(y==1)
  804. {
  805. display();
  806. }
  807. else
  808. {
  809. menu();
  810. }
  811. }
  812. case 2:
  813. {
  814. printf("\n1.Display All Student Information\n");
  815. printf("2.Display Same Batch Student\n");
  816. printf("3.Display Same Batch And Same Department Student\n");
  817. printf("Choose One:");
  818. int s;
  819. scanf("%d",&s);
  820. if(root_student==NULL)
  821. {
  822. printf("\nNo Student Information available!!!\n");
  823. }
  824. else if(s==1)
  825. {
  826.  
  827.  
  828.  
  829. displays(root_student); //displays=display student.
  830.  
  831. }
  832. else if(s==2)
  833. {
  834. printf("Enter Student Batch:");
  835. int batch;
  836. scanf("%d",&batch);
  837. displayb(root_student,batch);
  838. if(fs==0)
  839. {
  840. printf("\nNo Student Information Available!!\n\n");
  841. }
  842. else
  843. {
  844. fs=0;
  845. }
  846. }
  847. else if(s==3)
  848. {
  849. printf("Enter Department:");
  850. char d[70];
  851. int batch;
  852. scanf(" %[^\n]",d);
  853. printf("Enter the Batch:");
  854. scanf("%d",&batch);
  855. displaydb(root_student,batch,d);
  856. if(fds==0)
  857. {
  858. printf("\nNo Information Available!!!\n\n");
  859.  
  860. }
  861. else
  862. {
  863. fds=0;
  864. }
  865. }
  866. else
  867. {
  868. printf("Please Choose Correct option!!!\a");
  869. display();
  870. }
  871.  
  872. printf("\n1.Back\n");
  873. printf("\n2.Menu\n");
  874. int y;
  875. printf("Choose any One:");
  876. scanf("%d",&y);
  877. if(y==1)
  878. {
  879. display();
  880. }
  881. else
  882. {
  883. menu();
  884. }
  885. }
  886. case 3:
  887. {
  888. if(root_staff==NULL)
  889. {
  890. printf("\nNo Staff Information Available\n\n");
  891. }
  892. displayst(root_staff); //displayst=display staff information
  893. printf("\n1.Back\n");
  894. printf("\n2.Menu\n");
  895. int y;
  896. printf("Choose any One:");
  897. scanf("%d",&y);
  898. if(y==1)
  899. {
  900. display();
  901. }
  902. else
  903. {
  904. menu();
  905. }
  906. }
  907. case 4:
  908. {
  909. menu();
  910. }
  911. case 5:
  912. {
  913. exit(0);
  914. break;
  915. }
  916. default:
  917. {
  918. printf("Choose Correct Option:");
  919. display();
  920. }
  921. }
  922. }
  923.  
  924.  
  925.  
  926. void addcr() //for CR
  927. {
  928. node *newnode=(node*)malloc(sizeof(node));
  929. newnode->left=NULL;
  930. newnode->right=NULL;
  931. printf("Name Of the Department:");
  932. scanf(" %[^\n]",newnode->dept);
  933. printf("Student Name:");
  934. scanf(" %[^\n]",newnode->name);
  935. printf("Student ID:");
  936. scanf(" %s",newnode->id);
  937. printf("Section:");
  938. scanf(" %s",newnode->sec);
  939. printf("Phone No:");
  940. scanf(" %[^\n]",newnode->phone);
  941. printf("Batch:");
  942. scanf(" %d",&newnode->batch);
  943. printf("Blood Group:");
  944. scanf(" %s",newnode->blood);
  945. if(root_cr==NULL)
  946. {
  947. root_cr=newnode;
  948. }
  949. else
  950. {
  951. bst(root_cr,newnode); //bst=binary search tree
  952. }
  953. printf("\n\n1.back\n");
  954. printf("2.menu\n");
  955. printf("Choose Any One:");
  956. int x;
  957. scanf("%d",&x);
  958. if(x==1)
  959. {
  960. add();
  961. }
  962. else if(x==2)
  963. {
  964. menu();
  965. }
  966. else
  967. {
  968. printf("Please Choose Correct Option!!\n\n");
  969. menu();
  970. }
  971.  
  972. }
  973.  
  974. void adds() // for student
  975. {
  976. node *newnode=(node*)malloc(sizeof(node));
  977. newnode->left=NULL;
  978. newnode->right=NULL;
  979. printf("Name Of the Department:");
  980. scanf(" %[^\n]",newnode->dept);
  981. printf("Student Name:");
  982. scanf(" %[^\n]",newnode->name);
  983. printf("Student ID:");
  984. scanf(" %s",newnode->id);
  985. printf("Section:");
  986. scanf(" %s",newnode->sec);
  987. printf("Phone No:");
  988. scanf(" %[^\n]",newnode->phone);
  989. printf("Batch:");
  990. scanf("%d",&newnode->batch);
  991. printf("Blood Group:");
  992. scanf(" %s",newnode->blood);
  993. if(root_student==NULL)
  994. {
  995. root_student=newnode;
  996. }
  997. else
  998. {
  999. bst(root_student,newnode); //bst=binary search tree
  1000. }
  1001. printf("\n\n1.back\n");
  1002. printf("2.menu\n");
  1003. printf("Choose Any One:");
  1004. int x;
  1005. scanf("%d",&x);
  1006. if(x==1)
  1007. {
  1008. add();
  1009. }
  1010. else if(x==2)
  1011. {
  1012. menu();
  1013. }
  1014. else
  1015. {
  1016. printf("Please Choose Correct Option!!\n\n");
  1017. menu();
  1018. }
  1019.  
  1020.  
  1021. }
  1022.  
  1023.  
  1024.  
  1025. void addst() //for staff information
  1026. {
  1027. node *newnode=(node*)malloc(sizeof(node));
  1028. newnode->left=NULL;
  1029. newnode->right=NULL;
  1030.  
  1031. printf("Staff Name:");
  1032. scanf(" %[^\n]",newnode->name);
  1033. printf("Staff ID:");
  1034. scanf(" %s",newnode->id);
  1035. printf("Phone No:");
  1036. scanf(" %[^\n]",newnode->phone);
  1037. printf("Designation:");
  1038. scanf(" %[^\n]",newnode->designation);
  1039. printf("Blood Group:");
  1040. scanf(" %s",newnode->blood);
  1041. if(root_staff==NULL)
  1042. {
  1043. root_staff=newnode;
  1044. }
  1045. else
  1046. {
  1047. bst(root_staff,newnode); //bst=binary search tree
  1048. }
  1049. printf("\n\n1.back\n");
  1050. printf("2.menu\n");
  1051. printf("Choose Any One:");
  1052. int x;
  1053. scanf("%d",&x);
  1054. if(x==1)
  1055. {
  1056. add();
  1057. }
  1058. else if(x==2)
  1059. {
  1060. menu();
  1061. }
  1062. else
  1063. {
  1064. printf("Please Choose Correct Option!!\n\n");
  1065. menu();
  1066. }
  1067.  
  1068. }
  1069.  
  1070.  
  1071.  
  1072. void addt()
  1073. { node *newnode=(node*)malloc(sizeof(node));
  1074. newnode->left=NULL;
  1075. newnode->right=NULL;
  1076. printf("Name Of the Department:");
  1077. scanf(" %[^\n]",newnode->dept);
  1078. printf("Teacher's Name:");
  1079. scanf(" %[^\n]",newnode->name);
  1080. printf("Teacher's ID:");
  1081. scanf(" %s",newnode->id);
  1082. printf("Phone No:");
  1083. scanf(" %[^\n]",newnode->phone);
  1084. printf("Designation:");
  1085. scanf(" %[^\n]",newnode->designation);
  1086. if(root_teacher==NULL)
  1087. {
  1088. root_teacher=newnode;
  1089. }
  1090. else
  1091. {
  1092. bst(root_teacher,newnode); //bst=binary search tree
  1093. }
  1094. printf("\n\n1.back\n");
  1095. printf("2.menu\n");
  1096. printf("Choose Any One:");
  1097. int x;
  1098. scanf("%d",&x);
  1099. if(x==1)
  1100. {
  1101. add();
  1102. }
  1103. else if(x==2)
  1104. {
  1105. menu();
  1106. }
  1107. else
  1108. {
  1109. printf("Please Choose Correct Option!!\n\n");
  1110. menu();
  1111. }
  1112. }
  1113. void add()
  1114. {
  1115. printf("\n1.ADD TEACHER INFORMAION\n");
  1116. printf("2.ADD STUDENT INFORMATION\n");
  1117. printf("3.ADD STAFF INFORMATION\n");
  1118. printf("4.ADD CR INFORMATION\n");
  1119. printf("5.MENU\n");
  1120. printf("6.Exit\n");
  1121. int x;
  1122. printf("\nChoose Any One:");;
  1123. scanf("%d",&x);
  1124. switch(x)
  1125. {
  1126. case 1:
  1127. {
  1128. addt(); //addt()=add teacher information
  1129. break;
  1130. }
  1131. case 2:
  1132. {
  1133. adds(); //adds()=add student information
  1134. break;
  1135. }
  1136. case 3:
  1137. {
  1138. addst(); //addst=add staff information
  1139. break;
  1140. }
  1141. case 4:
  1142. {
  1143. addcr(); //addcr=add cr information
  1144. break;
  1145. }
  1146. case 5:
  1147. {
  1148. menu();
  1149. }
  1150. case 6:
  1151. {
  1152. exit(0);
  1153. break;
  1154. }
  1155. default:
  1156. {
  1157. printf("\nPlease choose Correct Option!!\a\n ");
  1158. add();
  1159. }
  1160. }
  1161. return;
  1162.  
  1163.  
  1164. }
  1165.  
  1166.  
  1167. void menu()
  1168. {
  1169. printf("\n 1.ADD INFORMATION");
  1170. printf(" 2.SEARCH INFORMATION");
  1171. printf("\n 3.DELETE INFORMATION");
  1172. printf("\n 4.DISPLAY INFORMATION");
  1173. printf(" 5.EXIT");
  1174. int x;
  1175. printf("\nChoose Any One:");
  1176. scanf("%d",&x);
  1177. switch(x)
  1178. {
  1179. case 1:
  1180. {
  1181.  
  1182. add();
  1183. break;
  1184. }
  1185. case 2:
  1186. {
  1187. search();
  1188. break;
  1189. }
  1190. case 3:
  1191. {
  1192. Delete();
  1193. break;
  1194.  
  1195. }
  1196. case 4:
  1197. {
  1198. display();
  1199.  
  1200. menu();
  1201. break;
  1202. }
  1203. case 5:
  1204. {
  1205. exit(0);
  1206. break;
  1207. }
  1208. default:
  1209. {
  1210. printf("\nPlease Choose Correct Option!!\a\n");
  1211. menu();
  1212. }
  1213. }
  1214. }
  1215.  
  1216.  
  1217. int main()
  1218. {
  1219. printf(" WELCOME TO FACULTY OF SCIENCE AND INFORMATION TECHNOLOGY\n");
  1220. printf(" ___________________________________________________________\n\n");
  1221. menu();
  1222. return 0;
  1223. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement