Advertisement
asiffff

Untitled

Apr 3rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.17 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <windows.h>
  5. #include <conio.h>
  6. struct student
  7. {
  8. int id;
  9. int cla;
  10. long int p_num;
  11. char group[20];
  12. char name[20];
  13. char name1[20];
  14. char gender[20];
  15. double bangla,english,math,physics,chemistry,biology;
  16. struct student *next,*prev;
  17. }*start=NULL,*end=NULL,*current;
  18.  
  19. void create()
  20. {
  21. char na[20];
  22. if(start==NULL && end==NULL)
  23. {
  24. struct student *new_node;
  25. new_node=(struct student*)malloc(1*sizeof(struct student));
  26. printf("Enter First Name: ");
  27. scanf("%s",&new_node->name);
  28. printf("\nEnter Last Name: ");
  29. scanf("%s",&new_node->name1);
  30. printf("\nEnter Gender: ");
  31. scanf("%s",&new_node->gender);
  32. printf("\nEnter Class: ");
  33. scanf("%d",&new_node->cla);
  34. printf("\nEnter ID: ");
  35. scanf("%d",&new_node->id);
  36. printf("\nEnter Group: ");
  37. scanf("%s",&new_node->group);
  38. printf("\nEnter Parents Phone Number: ");
  39. scanf("%ld",&new_node->p_num);
  40. new_node->next=NULL;
  41. new_node->prev=NULL;
  42. start=new_node;
  43. end=new_node;
  44. current=new_node;
  45. system("cls");
  46. }
  47. else
  48. {
  49. struct student *new_node;
  50. new_node=(struct student*)malloc(1*sizeof(struct student));
  51. printf("Enter First Name: ");
  52. scanf("%s",&new_node->name);
  53. printf("\nEnter Last Name: ");
  54. scanf("%s",&new_node->name1);
  55. printf("\nEnter Gender: ");
  56. scanf("%s",&new_node->gender);
  57. printf("\nEnter Class: ");
  58. scanf("%d",&new_node->cla);
  59. printf("\nEnter ID: ");
  60. scanf("%d",&new_node->id);
  61. printf("\nEnter Group: ");
  62. scanf("%s",&new_node->group);
  63. printf("\nEnter Parents Phone Number: ");
  64. scanf("%ld",&new_node->p_num);
  65. new_node->next=NULL;
  66. new_node->prev=NULL;
  67. current->next=new_node;
  68. new_node->prev=current;
  69. end=new_node;
  70. current=new_node;
  71. system("cls");
  72. }
  73. }
  74. void dis(int a)
  75. {
  76. int n=0,i=1;
  77. struct student *c;
  78. c=start;
  79. while(c!=NULL)
  80. {
  81. if(c->cla==a)
  82. {
  83. printf("%d. Name : %s %s Gender : %s\nClass : %d ID : %d\nGroup : %s Parents Phone Number: %ld\n",i,c->name,c->name1,c->gender,c->cla,c->id,c->group,c->p_num);
  84.  
  85. n++;
  86. }
  87. c=c->next;
  88. }
  89. //return n;
  90. if(n==0)
  91. printf("There is no student in this Class\n");
  92. else
  93. printf("Total Student %d",n);
  94. }
  95.  
  96. struct teacher
  97. {
  98. int id;
  99. char name[20];
  100. char name1[20];
  101. char gender[20];
  102. char group[20];
  103. long int phnum;
  104. struct teacher *next,*prev;
  105.  
  106. }*start1=NULL,*end1=NULL,*current1;
  107. void create1()
  108. {
  109. struct teacher *new_node;
  110. if(start1==NULL && end1==NULL)
  111. {
  112. new_node=(struct teacher*)malloc(1*sizeof(struct teacher));
  113. printf("Enter First Name: ");
  114. scanf("%s",&new_node->name);
  115. printf("\nEnter Last Name: ");
  116. scanf("%s",&new_node->name1);
  117. printf("\nEnter ID: ");
  118. scanf("%d",&new_node->id);
  119. printf("\nEnter Group: ");
  120. scanf("%s",&new_node->group);
  121. printf("\nEnter Gender: ");
  122. scanf("%s",&new_node->gender);
  123. printf("\nEnter Phone Number: ");
  124. scanf("%ld",&new_node->phnum);
  125. new_node->next=NULL;
  126. new_node->prev=NULL;
  127.  
  128. start1=new_node;
  129. end1=new_node;
  130. current1=new_node;
  131. system("cls");
  132.  
  133. }
  134. else
  135. {
  136. new_node=(struct teacher*)malloc(1*sizeof(struct teacher));
  137. printf("Enter First Name: ");
  138. scanf("%s",&new_node->name);
  139. printf("\nEnter Last Name: ");
  140. scanf("%s",&new_node->name1);
  141. printf("\nEnter ID: ");
  142. scanf("%d",&new_node->id);
  143. printf("\nEnter Group: ");
  144. scanf("%s",&new_node->group);
  145. printf("\nEnter Gender: ");
  146. scanf("%s",&new_node->gender);
  147. printf("\nEnter Phone Number: ");
  148. scanf("%ld",&new_node->phnum);
  149. new_node->next=NULL;
  150. new_node->prev=NULL;
  151.  
  152. current1->next=new_node;
  153. new_node->prev=current1;
  154. current1=new_node;
  155. end1=new_node;
  156. system("cls");
  157. }
  158.  
  159.  
  160.  
  161. }
  162. void dis1()
  163. {
  164. struct teacher *c;
  165. c=start1;
  166. while(c!=NULL)
  167. {
  168. printf("Teacher ID:%d\n",c->id);
  169. printf("Your group:%s\n",c->group);
  170. printf("Teacher Name:%s %s\n",c->name,c->name1);
  171. printf("Teacher Gender:%s\n",c->gender);
  172. printf("Teacher Phone number:%ld\n",c->phnum);
  173. c=c->next;
  174. }
  175. }
  176. int search(int a,int y)
  177. {
  178. struct student *c;
  179. struct teacher *c1;
  180. int po=0;
  181. if(a!=0 && y!=0)
  182. {
  183. c=start;
  184. while(c!=NULL)
  185. {
  186. po++;
  187. if(c->cla==a && c->id)
  188. {
  189. return po;
  190. }
  191. c=c->next;
  192. }
  193. return -1;
  194. }
  195. else
  196. {
  197. c1=start1;
  198. while(c1!=NULL)
  199. {
  200. po++;
  201. if(c1->id==a)
  202. {
  203. return po;
  204. }
  205. c1=c1->next;
  206. }
  207. return -1;
  208.  
  209. }
  210. }
  211. void print1()
  212. {
  213. printf("\n\n\n");
  214. printf("\t\t\t1.Enter Student Details.\n");
  215. printf("\t\t\t2.View All Student Details\n");
  216. printf("\t\t\t3.Search Student Details.\n");
  217. printf("\t\t\t4.Enter Teacher Details.\n");
  218. printf("\t\t\t5.View All Teacher Details\n");
  219. printf("\t\t\t6.Search Teacher Details.\n");
  220. printf("\t\t\t7.Enter Student Results\n");
  221. printf("\t\t\t8.View Student Result\n");
  222. printf("\t\t\t9.Exit.\n");
  223. }
  224. void print2()
  225. {
  226. printf("\n\n\n");
  227. //printf("\t\t\t1.Enter Student Details.\n");
  228. printf("\t\t\t1.View All Student Details\n");
  229. //printf("\t\t\t3.Search Student Details.\n");
  230. //printf("\t\t\t4.Enter Teacher Details.\n");
  231. printf("\t\t\t2.View All Teacher Details\n");
  232. printf("\t\t\t3.Search Teacher Details.\n");
  233. //printf("\t\t\t7.Enter Student Results\n");
  234. printf("\t\t\t4.View Student Result\n");
  235. printf("\t\t\t5.Exit.\n");
  236. }
  237. void cls()
  238. {
  239. system("cls");
  240. }
  241.  
  242. void print()
  243. {
  244. int i;
  245. printf(" ");
  246. for(i=1; i<=59; i++)
  247. {
  248. printf("* ");
  249. }
  250. printf("\n\n");
  251. printf("\t\t\t\t DAFFODIL INTERNATIONAL SCHOOL\n\n");
  252. printf(" ");
  253. for(i=1; i<=59; i++)
  254. {
  255. printf("* ");
  256. }
  257. printf("\n");
  258. }
  259. void admin_and_student(int z)
  260. {
  261. int exit = 0,x;
  262. while(1)
  263. {
  264.  
  265. if(exit==1)
  266. {
  267. break;
  268. }
  269. //int x;
  270. cls();
  271. print();
  272. if(z==1) {
  273. print1();
  274. }
  275. else if(z==2)
  276. {
  277. print2();
  278. }
  279. scanf("%d",&x);
  280. if(z==2)
  281. {
  282. if(x==1) x=2;
  283. else if(x==2) x=5;
  284. else if(x==3) x=6;
  285. else if(x==4) x=8;
  286. else if(x==5) x=9;
  287. }
  288. switch(x)
  289. {
  290. case 1:
  291. {
  292. while(1)
  293. {
  294. system("cls");
  295. print();
  296. create();
  297. print();
  298. printf("\t\tDo you want to continue?\n");
  299. printf("1.Yes 2.No\n");
  300. int e;
  301. scanf("%d",&e);
  302. if(e==1)
  303. continue;
  304. else
  305. break;
  306. }
  307. system("cls");
  308. break;
  309. }
  310. case 2:
  311. {
  312. system("cls");
  313. print();
  314. printf("\t\t\t\t1.Class 6\n\t\t\t\t2.Class 7.\n\t\t\t\t3.Class 8.\n\t\t\t\t4.Class 9.\n\t\t\t\t5.Class 10.\n");
  315. int e;
  316. scanf("%d",&e);
  317. system("cls");
  318. switch(e)
  319. {
  320. case 1:
  321. {
  322. system("cls");
  323. print();
  324. dis(6);
  325. getch();
  326. system("cls");
  327. break;
  328. }
  329. case 2:
  330. {
  331. system("cls");
  332. print();
  333. dis(7);
  334. getch();
  335. system("cls");
  336. break;
  337. }
  338. case 3:
  339. {
  340. system("cls");
  341. print();
  342. dis(8);
  343. getch();
  344. break;
  345. }
  346. case 4:
  347. {
  348. system("cls");
  349. print();
  350. dis(9);
  351. getch();
  352. break;
  353. }
  354. case 5:
  355. {
  356. system("cls");
  357. print();
  358. dis(10);
  359. getch();
  360. break;
  361. }
  362. }
  363. //dis();
  364. print();
  365. printf("\n\n\nPress any key to quit.");
  366. getch();
  367. system("cls");
  368. break;
  369. }
  370. case 3:
  371. {
  372. while(1)
  373. {
  374. system("cls");
  375. print();
  376. int x1,y1;
  377. printf("\n\n\nEnter Class: ");
  378. scanf("%d",&x1);
  379. printf("\nEnter Student ID: ");
  380. scanf("%d",&y1);
  381. system("cls");
  382. //print();
  383. int pos = search(x1,y1);
  384. if(pos==-1)
  385. {
  386. print();
  387. printf("\n\n\nNot Found");
  388. getch();
  389. system("cls");
  390. }
  391. else
  392. {
  393. print();
  394. struct student *b;
  395. b=start;
  396. int j;
  397. for(j=0; j<pos-1; j++)
  398. {
  399. b=b->next;
  400. }
  401. printf("\n\n\nName : %s %s\nGender : %s\nClass : %d\nID : %d\nGroup : %s\nParents Number : %ld\n",b->name,b->name1,b->gender,b->cla,b->id,b->group,b->p_num);
  402. printf("\n\nPress any key.");
  403. getch();
  404. system("cls");
  405. }
  406. print();
  407. printf("\n\n\nDo you want to search another?\n 1.Yes 2.No\n");
  408. int e;
  409. scanf("%d",&e);
  410. if(e==1)
  411. continue;
  412. else if(e==2)
  413. break;
  414.  
  415. }
  416. system("cls");
  417. break;
  418. }
  419. case 4:
  420. {
  421. while(1)
  422. {
  423. system("cls");
  424. print();
  425. create1();
  426. int e;
  427. print();
  428. printf("\n\n\nDo you want to Continue?\n1.Yes 2.No\n");
  429. scanf("%d",&e);
  430. if(e==1)
  431. continue;
  432. else if(e==2)
  433. break;
  434. }
  435. system("cls");
  436. break;
  437. }
  438. case 5:
  439. {
  440. system("cls");
  441. print();
  442. dis1();
  443. getch();
  444. system("cls");
  445. break;
  446. }
  447. case 6:
  448. {
  449. while(1)
  450. {
  451. system("cls");
  452. print();
  453. printf("\n\n\nEnter Id:\n");
  454. int k;
  455. scanf("%d",&k);
  456. int pos1 = search(k,0);
  457. if(pos1==-1)
  458. {
  459. system("cls");
  460. print();
  461. printf("\n\n\nNot Found\n");
  462. getch();
  463. system("cls");
  464. }
  465. else
  466. {
  467. system("cls");
  468. print();
  469. struct teacher *c;
  470. c=start1;
  471. int j;
  472. for(j=0; j<pos1-1; j++)
  473. {
  474. c=c->next;
  475. }
  476. printf("\n\n\nTeacher Name :%s\n",c->name);
  477. printf("\nTeacher ID :%d",c->id);
  478. printf("\nGroup :%s",c->group);
  479. printf("\nTeacher Gender :%s",c->gender);
  480. printf("\nPhone number :%ld",c->phnum);
  481. getch();
  482. system("cls");
  483.  
  484. }
  485. print();
  486. printf("\n\n\nDo you want to continue?\n1.Yes 2.No\n");
  487. int e;
  488. scanf("%d",&e);
  489. if(e==1)
  490. continue;
  491. else
  492. break;
  493. }
  494. system("cls");
  495. break;
  496. }
  497. case 7:
  498. {
  499. while(1)
  500. {
  501. system("cls");
  502. print();
  503. int x1,y1;
  504. printf("\n\n\nEnter Class: ");
  505. scanf("%d",&x1);
  506. printf("\nEnter Student ID: ");
  507. scanf("%d",&y1);
  508. system("cls");
  509. int k;
  510. //y=2;
  511. int pos1 = search(x1,y1);
  512. if(pos1==-1)
  513. {
  514. system("cls");
  515. print();
  516. printf("\n\n\nNot Found\n");
  517. getch();
  518.  
  519. }
  520. else
  521. {
  522. print();
  523. struct student *c;
  524. c=start;
  525. int j;
  526. for(j=0; j<pos1-1; j++)
  527. {
  528. c=c->next;
  529. }
  530. printf("\n\n\nName : %s %s\n",c->name,c->name1);
  531. printf("Bangla : ");
  532. scanf("%lf",&c->bangla);
  533. printf("\nEnglish: ");
  534. scanf("%lf",&c->english);
  535. printf("\nMath: ");
  536. scanf("%lf",&c->math);
  537. printf("\nPhysics: ");
  538. scanf("%lf",&c->physics);
  539. printf("\nChemistry: ");
  540. scanf("%lf",&c->chemistry);
  541. printf("\nBiology: ");
  542. scanf("%lf",&c->biology);
  543. //getch();
  544. system("cls");
  545. }
  546. int e;
  547. print();
  548. printf("\n\nDo you want to continue?\n1.Yes 2.No\n");
  549. scanf("%d",&e);
  550. if(e==1)
  551. continue;
  552. else
  553. break;
  554.  
  555. }
  556. system("cls");
  557. break;
  558. }
  559. case 8:
  560. {
  561. while(1)
  562. {
  563. system("cls");
  564. print();
  565. int x1,y1;
  566. printf("\n\nEnter Class: ");
  567. scanf("%d",&x1);
  568. printf("\nEnter Student ID: ");
  569. scanf("%d",&y1);
  570. system("cls");
  571. int k;
  572. int pos1 = search(x1,y1);
  573. if(pos1==-1)
  574. {
  575. printf("Not Found\n");
  576. getch();
  577. system("cls");
  578. }
  579. else
  580. {
  581. system("cls");
  582. struct student *c;
  583. c=start;
  584. int j;
  585. for(j=0; j<pos1-1; j++)
  586. {
  587. c=c->next;
  588. }
  589. print();
  590.  
  591. printf("\n\nName : %s %s Group: %s\nClass : %d Roll : %d\n",c->name,c->name1,c->group,c->cla,c->id);
  592. printf("Bangla : %.2lf\n",c->bangla);
  593. printf("\nEnglish: %.2lf\n",c->english);
  594.  
  595. printf("\nMath: %.2lf\n",c->math);
  596.  
  597. printf("\nPhysics: %.2lf\n",c->physics);
  598.  
  599. printf("\nChemistry: %.2lf\n",c->chemistry);
  600.  
  601. printf("\nBiology: %.2lf\n",c->biology);
  602.  
  603. getch();
  604. system("cls");
  605.  
  606. }
  607. int e;
  608. print();
  609. printf("Do you want to continue?\n1.Yes 2.No\n");
  610. scanf("%d",&e);
  611. if(e==1)
  612. continue;
  613. else if(e==2)
  614. break;
  615. }
  616. system("cls");
  617. break;
  618.  
  619.  
  620. }
  621. case 9:
  622. {
  623. exit = 1;
  624. break;
  625. }
  626.  
  627. }
  628. }
  629. }
  630. void admin()
  631. {
  632. int d=0;
  633. char c[10],p[10];
  634. while(1)
  635. {
  636.  
  637. system("cls");
  638. print();
  639. if(d==1)
  640. {
  641. system("cls");
  642. print();
  643. printf("\t\t\tWrong Password! Try again.");
  644. }
  645. printf("\n\n\n");
  646. printf("\t\t\t\tEnter User Name: ");
  647. scanf("%s",c);
  648. printf("\n");
  649. printf("\t\t\t\tEnter Password: ");
  650. scanf("%s",&p);
  651. if(strcmp(c,"techy5")==0 && strcmp(p,"121172")==0)
  652. {
  653. system("cls");
  654. print();
  655. printf("\t\t\tWelcome To Daffodil International School.\n\n\n");
  656. printf("\t\t\tPress any key to enter in the Admin Panel\n");
  657. getch();
  658. system("cls");
  659. break;
  660. }
  661. else
  662. {
  663. system("cls");
  664. d=1;
  665. //printf("Wrong Password! Try again.\n");
  666. continue;
  667. }
  668. }
  669. }
  670.  
  671. int main()
  672. {
  673. int x,y,ex=0,d=0;
  674. char c[10],p[10];
  675. while(1)
  676. {
  677. cls();
  678. print();
  679. printf("\n\n\n");
  680. printf("1.Admin Panel.\n\n2.Student Panel.\n\n3.Exit.\n\n");
  681. scanf("%d",&x);
  682. switch(x)
  683. {
  684. case 1:
  685. {
  686. admin();
  687. //getch();
  688. admin_and_student(1);
  689. break;
  690.  
  691. }
  692. case 2:
  693. {
  694. admin_and_student(2);
  695. break;
  696. }
  697. }
  698. }
  699. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement