Advertisement
asiffff

pB5

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