Advertisement
asiffff

Untitled

Mar 29th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.91 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 dis1()
  185. {
  186. struct teacher *c;
  187. c=start1;
  188. while(c!=NULL)
  189. {
  190. printf("\nTeacher ID:%d\n",c->id);
  191. printf("Your group:%s\n",c->group);
  192. printf("Teacher Name:%s\n",c->name);
  193. printf("Teacher Gender:%s\n",c->gender);
  194. printf("Teacher Phone number:%ld\n",c->phnum);
  195. c=c->next;
  196. }
  197. }
  198. void result()
  199. {
  200. int cls,id;
  201. printf("\nEnter Class and ID NO:\n");
  202. scanf("%d %d",&cls,&id);
  203. struct student *n,*c;
  204. c=start;
  205. int po=0;
  206. while(c!=NULL)
  207. {
  208. po++;
  209. if(c->cla==cls && c->id==id)
  210. {
  211. break;
  212. }
  213. c=c->next;
  214. }
  215.  
  216.  
  217. }
  218.  
  219. int main()
  220. {
  221. int x,y,ex=0,d=0;
  222. char c[10],p[10];
  223. while(1)
  224. {
  225.  
  226. if(d==1)
  227. {
  228. printf("\t\t\tWrong Password! Try again.");
  229. }
  230. printf("\n\n\n");
  231. printf("\t\t\tEnter User Name: ");
  232. scanf("%s",c);
  233. printf("\n");
  234. printf("\t\t\tEnter Password: ");
  235. scanf("%s",&p);
  236. if(strcmp(c,"techy5")==0 && strcmp(p,"121172")==0)
  237. {
  238. system("cls");
  239. d=0;
  240. break;
  241. }
  242. else
  243. {
  244. system("cls");
  245. d=1;
  246. //printf("Wrong Password! Try again.\n");
  247. continue;
  248. }
  249. }
  250.  
  251. while(1)
  252. {
  253. if(d==0)
  254. {
  255. printf("\t\t\tWelcome To Daffodil International School.\n\n\n");
  256. printf("\t\t\tPress any key to enter in the Admin Panel\n");
  257. getch();
  258. system("cls");
  259. }
  260. if(ex==1)
  261. {
  262. system("cls");
  263. printf("Thank You.\n");
  264. printf("By : Techy5\n");
  265. getch();
  266. system("cls");
  267. break;
  268. }
  269.  
  270. printf("1.Enter Student Details.\n2.View All Student Details\n3.Search Student Details.\n");
  271. printf("4.Enter Teacher Details.\n5.View All Teacher Details\n6.Search Teacher Details.\n");
  272. printf("7.Enter Student Results\n8.View Student Result\n9.Exit\n");
  273. scanf("%d",&x);
  274. switch(x)
  275. {
  276. case 1:
  277. {
  278. while(1)
  279. {
  280. system("cls");
  281. create();
  282. printf("Do you want to continue?\n");
  283. printf("1.Yes 2.No\n");
  284. int e;
  285. scanf("%d",&e);
  286. if(e==1)
  287. continue;
  288. else
  289. break;
  290. }
  291. system("cls");
  292. break;
  293. }
  294. case 2:
  295. {
  296. system("cls");
  297. printf("1.Class 6\n2.Class 7.\n3.Class 8.\n4.Class 9.\n5.Class 10.\n");
  298. int e;
  299. scanf("%d",&e);
  300. system("cls");
  301. switch(e)
  302. {
  303. case 1:
  304. {
  305. dis(6);
  306. break;
  307. }
  308. case 2:
  309. {
  310. dis(7);
  311. break;
  312. }
  313. case 3:
  314. {
  315. dis(8);
  316. break;
  317. }
  318. case 4:
  319. {
  320. dis(9);
  321. break;
  322. }
  323. case 5:
  324. {
  325. dis(10);
  326. break;
  327. }
  328. }
  329. //dis();
  330. printf("Press any key to quit.");
  331. getch();
  332. system("cls");
  333. break;
  334. }
  335. case 3:
  336. {
  337. while(1)
  338. {
  339. system("cls");
  340. int x1,y1;
  341. printf("Enter Class: ");
  342. scanf("%d",&x1);
  343. printf("\nEnter Student ID: ");
  344. scanf("%d",&y1);
  345. system("cls");
  346. int pos = search(x1,y1);
  347. if(pos==-1)
  348. {
  349. printf("Not Found");
  350. getch();
  351. system("cls");
  352. }
  353. else
  354. {
  355. struct student *b;
  356. b=start;
  357. int j;
  358. for(j=0; j<pos-1; j++)
  359. {
  360. b=b->next;
  361. }
  362. 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);
  363. printf("Press any key.");
  364. getch();
  365. system("cls");
  366. }
  367. printf("Do you want to search another?\n 1.Yes 2.No\n");
  368. int e;
  369. scanf("%d",&e);
  370. if(e==1)
  371. continue;
  372. else if(e==2)
  373. break;
  374.  
  375. }
  376. system("cls");
  377. break;
  378. }
  379. case 4:
  380. {
  381. while(1)
  382. {
  383. system("cls");
  384. create1();
  385. int e;
  386. printf("Do you want to Continue?\n1.Yes 2.No\n");
  387. scanf("%d",&e);
  388. if(e==1)
  389. continue;
  390. else if(e==2)
  391. break;
  392. }
  393. system("cls");
  394. break;
  395. }
  396. case 5:
  397. {
  398. dis1();
  399. getch();
  400. system("cls");
  401. break;
  402. }
  403. case 6:
  404. {
  405. while(1)
  406. {
  407. system("cls");
  408. printf("Enter Id:\n");
  409. int k;
  410. scanf("%d",&k);
  411. int pos1 = search(k,0);
  412. if(pos1==-1)
  413. {
  414. system("cls");
  415. printf("Not Found\n");
  416. getch();
  417. system("cls");
  418. }
  419. else
  420. {
  421. struct teacher *c;
  422. c=start1;
  423. int j;
  424. for(j=0; j<pos1-1; j++)
  425. {
  426. c=c->next;
  427. }
  428. printf("\nTeacher ID:%d\n",c->id);
  429. printf("Your group:%s\n",c->group);
  430. printf("Teacher Name:%s\n",c->name);
  431. printf("Teacher Gender:%s\n",c->gender);
  432. printf("Teacher Phone number:%ld\n",c->phnum);
  433. getch();
  434. system("cls");
  435.  
  436. }
  437. printf("Do you want to continue?\n1.Yes 2.No\n");
  438. int e;
  439. scanf("%d",&e);
  440. if(e==1)
  441. continue;
  442. else
  443. break;
  444. }
  445. system("cls");
  446. break;
  447. }
  448. case 7:
  449. {
  450. while(1)
  451. {
  452. system("cls");
  453. int x1,y1;
  454. printf("Enter Class: ");
  455. scanf("%d",&x1);
  456. printf("Enter Student ID: ");
  457. scanf("%d",&y1);
  458. system("cls");
  459. int k;
  460. //y=2;
  461. int pos1 = search(x1,y1);
  462. if(pos1==-1)
  463. {
  464. printf("Not Found\n");
  465. getch();
  466.  
  467. }
  468. else
  469. {
  470. struct student *c;
  471. c=start;
  472. int j;
  473. for(j=0; j<pos1-1; j++)
  474. {
  475. c=c->next;
  476. }
  477. printf("Name : %s\n",c->name);
  478. printf("Bangla :\n");
  479. scanf("%lf",&c->bangla);
  480. printf("English:\n");
  481. scanf("%lf",&c->english);
  482. printf("Math:\n");
  483. scanf("%lf",&c->math);
  484. printf("Physics:\n");
  485. scanf("%lf",&c->physics);
  486. printf("Chemistry:\n");
  487. scanf("%lf",&c->chemistry);
  488. printf("Biology:\n");
  489. scanf("%lf",&c->biology);
  490. //getch();
  491. system("cls");
  492. }
  493. int e;
  494. printf("Do you want to continue?\n1.Yes 2.No\n");
  495. scanf("%d",&e);
  496. if(e==1)
  497. continue;
  498. else
  499. break;
  500.  
  501. }
  502. system("cls");
  503. break;
  504. }
  505. case 8:
  506. {
  507. while(1)
  508. {
  509. system("cls");
  510. int x1,y1;
  511. printf("Enter Class: ");
  512. scanf("%d",&x1);
  513. printf("Enter Student ID: ");
  514. scanf("%d",&y1);
  515. system("cls");
  516. int k;
  517. int pos1 = search(x1,y1);
  518. if(pos1==-1)
  519. {
  520. printf("Not Found\n");
  521. getch();
  522. system("cls");
  523. }
  524. else
  525. {
  526. system("cls");
  527. struct student *c;
  528. c=start;
  529. int j;
  530. for(j=0; j<pos1-1; j++)
  531. {
  532. c=c->next;
  533. }
  534. printf("Name : %s Group: %s\nClass : %d Roll : %d\n",c->name,c->group,c->cla,c->id);
  535. printf("Bangla : %.2lf\n",c->bangla);
  536. printf("English: %.2lf\n",c->english);
  537.  
  538. printf("Math: %.2lf\n",c->math);
  539.  
  540. printf("Physics: %.2lf\n",c->physics);
  541.  
  542. printf("Chemistry: %.2lf\n",c->chemistry);
  543.  
  544. printf("Biology: %.2lf\n",c->biology);
  545.  
  546. getch();
  547. system("cls");
  548.  
  549. }
  550. int e;
  551. printf("Do you want to continue?\n1.Yes 2.No\n");
  552. scanf("%d",&e);
  553. if(e==1)
  554. continue;
  555. else if(e==2)
  556. break;
  557. }
  558. system("cls");
  559. break;
  560.  
  561.  
  562. }
  563. case 9:
  564. {
  565. ex = 1;
  566. break;
  567. }
  568.  
  569. }
  570. }
  571. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement