asiffff

Project beta 3

Mar 28th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.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 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. printf("\nEnter Gender: ");
  51. scanf("%s",&new_node->gender);
  52. scanf("%d",&new_node->cla);
  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()
  69. {
  70. struct student *c;
  71. c=start;
  72. while(c!=NULL)
  73. {
  74. 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);
  75. c=c->next;
  76. }
  77. }
  78.  
  79. struct teacher
  80. {
  81. int id;
  82. char name[20];
  83. char gender[20];
  84. char group[20];
  85. long int phnum;
  86. struct teacher *next,*prev;
  87.  
  88. }*start1=NULL,*end1=NULL,*current1;
  89. void create1()
  90. {
  91. struct teacher *new_node;
  92. if(start1==NULL && end1==NULL)
  93. {
  94. new_node=(struct teacher*)malloc(1*sizeof(struct teacher));
  95. printf("\nEnter the number of teacher id:\n");
  96. scanf("%d",&new_node->id);
  97. printf("\nEnter your group:\n");
  98. scanf("%s",&new_node->group);
  99. printf("\nEnter the teacher name:\n");
  100. scanf("%s",&new_node->name);
  101. printf("\nEnter the teacher gender:\n");
  102. scanf("%s",&new_node->gender);
  103. printf("\nEnter the teacher phone number:\n");
  104. scanf("%ld",&new_node->phnum);
  105. new_node->next=NULL;
  106. new_node->prev=NULL;
  107.  
  108. start1=new_node;
  109. end1=new_node;
  110. current1=new_node;
  111. system("cls");
  112.  
  113. }
  114. else
  115. {
  116. new_node=(struct teacher*)malloc(1*sizeof(struct teacher));
  117. printf("\nEnter Teacher ID:\n");
  118. scanf("%d",&new_node->id);
  119. printf("\nEnter Teacher Group:\n");
  120. scanf("%s",&new_node->group);
  121. printf("\nEnter the teacher name:\n");
  122. scanf("%s",&new_node->name);
  123. printf("\nEnter the teacher gender:\n");
  124. scanf("%s",&new_node->gender);
  125. printf("\nEnter the teacher phone number:\n");
  126. scanf("%ld",&new_node->phnum);
  127. new_node->next=NULL;
  128. new_node->prev=NULL;
  129.  
  130. current1->next=new_node;
  131. new_node->prev=current1;
  132. current1=new_node;
  133. end1=new_node;
  134. system("cls");
  135. }
  136.  
  137.  
  138.  
  139. }
  140. int search(int a,int y)
  141. {
  142. struct student *c;
  143. struct teacher *c1;
  144. int po=0;
  145. if(a!=0 && y!=0)
  146. {
  147. c=start;
  148. while(c!=NULL)
  149. {
  150. po++;
  151. if(c->cla==a && c->id)
  152. {
  153. return po;
  154. }
  155. c=c->next;
  156. }
  157. return -1;
  158. }
  159. else
  160. {
  161. c1=start1;
  162. while(c1!=NULL)
  163. {
  164. po++;
  165. if(c1->id==a)
  166. {
  167. return po;
  168. }
  169. c1=c1->next;
  170. }
  171. return -1;
  172.  
  173. }
  174. }
  175. void dis1()
  176. {
  177. struct teacher *c;
  178. c=start1;
  179. while(c!=NULL)
  180. {
  181. printf("\nTeacher ID:%d\n",c->id);
  182. printf("Your group:%s\n",c->group);
  183. printf("Teacher Name:%s\n",c->name);
  184. printf("Teacher Gender:%s\n",c->gender);
  185. printf("Teacher Phone number:%ld\n",c->phnum);
  186. c=c->next;
  187. }
  188. }
  189. void result()
  190. {
  191. int cls,id;
  192. printf("\nEnter Class and ID NO:\n");
  193. scanf("%d %d",&cls,&id);
  194. struct student *n,*c;
  195. c=start;
  196. int po=0;
  197. while(c!=NULL)
  198. {
  199. po++;
  200. if(c->cla==cls && c->id==id)
  201. {
  202. break;
  203. }
  204. c=c->next;
  205. }
  206.  
  207.  
  208. }
  209.  
  210. int main()
  211. {
  212. int x,y,ex=0;
  213. while(1)
  214. {
  215. if(ex==1)
  216. {
  217. system("cls");
  218. printf("Thank You.\n");
  219. printf("By : Techy5\n");
  220. getch();
  221. system("cls");
  222. break;
  223. }
  224.  
  225. printf("1.Enter Student Details.\n2.View All Student Details\n3.Search Student Details.\n");
  226. printf("4.Enter Teacher Details.\n5.View All Teacher Details\n6.Search Teacher Details.\n");
  227. printf("7.Enter Student Results\n8.View Student Result\n9.Exit\n");
  228. scanf("%d",&x);
  229. switch(x)
  230. {
  231. case 1:
  232. {
  233. while(1)
  234. {
  235. system("cls");
  236. create();
  237. printf("Do you want to continue?\n");
  238. printf("1.Yes 2.No\n");
  239. int e;
  240. scanf("%d",&e);
  241. if(e==1)
  242. continue;
  243. else
  244. break;
  245. }
  246. system("cls");
  247. break;
  248. }
  249. case 2:
  250. {
  251. system("cls");
  252. dis();
  253. printf("Press any key to quit.");
  254. getch();
  255. system("cls");
  256. break;
  257. }
  258. case 3:
  259. {
  260. while(1)
  261. {
  262. system("cls");
  263. int x1,y1;
  264. printf("Enter Class: ");
  265. scanf("%d",&x1);
  266. printf("\nEnter Student ID: ");
  267. scanf("%d",&y1);
  268. system("cls");
  269. int pos = search(x1,y1);
  270. if(pos==-1)
  271. {
  272. printf("Not Found");
  273. getch();
  274. system("cls");
  275. }
  276. else
  277. {
  278. struct student *b;
  279. b=start;
  280. int j;
  281. for(j=0; j<pos-1; j++)
  282. {
  283. b=b->next;
  284. }
  285. 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);
  286. printf("Press any key.");
  287. getch();
  288. system("cls");
  289. }
  290. printf("Do you want to search another?\n 1.Yes 2.No\n");
  291. int e;
  292. scanf("%d",&e);
  293. if(e==1)
  294. continue;
  295. else if(e==2)
  296. break;
  297.  
  298. }
  299. system("cls");
  300. break;
  301. }
  302. case 4:
  303. {
  304. while(1)
  305. {
  306. system("cls");
  307. create1();
  308. int e;
  309. printf("Do you want to Continue?\n1.Yes 2.No\n");
  310. scanf("%d",&e);
  311. if(e==1)
  312. continue;
  313. else if(e==2)
  314. break;
  315. }
  316. system("cls");
  317. break;
  318. }
  319. case 5:
  320. {
  321. dis1();
  322. getch();
  323. system("cls");
  324. break;
  325. }
  326. case 6:
  327. {
  328. while(1)
  329. {
  330. system("cls");
  331. printf("Enter Id:\n");
  332. int k;
  333. scanf("%d",&k);
  334. int pos1 = search(k,0);
  335. if(pos1==-1)
  336. {
  337. system("cls");
  338. printf("Not Found\n");
  339. getch();
  340. system("cls");
  341. }
  342. else
  343. {
  344. struct teacher *c;
  345. c=start1;
  346. int j;
  347. for(j=0; j<pos1-1; j++)
  348. {
  349. c=c->next;
  350. }
  351. printf("\nTeacher ID:%d\n",c->id);
  352. printf("Your group:%s\n",c->group);
  353. printf("Teacher Name:%s\n",c->name);
  354. printf("Teacher Gender:%s\n",c->gender);
  355. printf("Teacher Phone number:%ld\n",c->phnum);
  356. getch();
  357. system("cls");
  358.  
  359. }
  360. printf("Do you want to continue?\n1.Yes 2.No\n");
  361. int e;
  362. scanf("%d",&e);
  363. if(e==1)
  364. continue;
  365. else
  366. break;
  367. }
  368. system("cls");
  369. break;
  370. }
  371. case 7:
  372. {
  373. while(1)
  374. {
  375. system("cls");
  376. int x1,y1;
  377. printf("Enter Class: ");
  378. scanf("%d",&x1);
  379. printf("Enter Student ID: ");
  380. scanf("%d",&y1);
  381. system("cls");
  382. int k;
  383. //y=2;
  384. int pos1 = search(x1,y1);
  385. if(pos1==-1)
  386. {
  387. printf("Not Found\n");
  388. getch();
  389.  
  390. }
  391. else
  392. {
  393. struct student *c;
  394. c=start;
  395. int j;
  396. for(j=0; j<pos1-1; j++)
  397. {
  398. c=c->next;
  399. }
  400. printf("Name : %s\n",c->name);
  401. printf("Bangla :\n");
  402. scanf("%lf",&c->bangla);
  403. printf("English:\n");
  404. scanf("%lf",&c->english);
  405. printf("Math:\n");
  406. scanf("%lf",&c->math);
  407. printf("Physics:\n");
  408. scanf("%lf",&c->physics);
  409. printf("Chemistry:\n");
  410. scanf("%lf",&c->chemistry);
  411. printf("Biology:\n");
  412. scanf("%lf",&c->biology);
  413. //getch();
  414. system("cls");
  415. }
  416. int e;
  417. printf("Do you want to continue?\n1.Yes 2.No\n");
  418. scanf("%d",&e);
  419. if(e==1)
  420. continue;
  421. else
  422. break;
  423.  
  424. }
  425. system("cls");
  426. break;
  427. }
  428. case 8:
  429. {
  430. while(1)
  431. {
  432. system("cls");
  433. int x1,y1;
  434. printf("Enter Class: ");
  435. scanf("%d",&x1);
  436. printf("Enter Student ID: ");
  437. scanf("%d",&y1);
  438. system("cls");
  439. int k;
  440. int pos1 = search(x1,y1);
  441. if(pos1==-1)
  442. {
  443. printf("Not Found\n");
  444. getch();
  445. system("cls");
  446. }
  447. else
  448. {
  449. system("cls");
  450. struct student *c;
  451. c=start;
  452. int j;
  453. for(j=0; j<pos1-1; j++)
  454. {
  455. c=c->next;
  456. }
  457. printf("Name : %s Group: %s\nClass : %d Roll : %d\n",c->name,c->group,c->cla,c->id);
  458. printf("Bangla : %.2lf\n",c->bangla);
  459. printf("English: %.2lf\n",c->english);
  460.  
  461. printf("Math: %.2lf\n",c->math);
  462.  
  463. printf("Physics: %.2lf\n",c->physics);
  464.  
  465. printf("Chemistry: %.2lf\n",c->chemistry);
  466.  
  467. printf("Biology: %.2lf\n",c->biology);
  468.  
  469. getch();
  470. system("cls");
  471.  
  472. }
  473. int e;
  474. printf("Do you want to continue?\n1.Yes 2.No\n");
  475. scanf("%d",&e);
  476. if(e==1)
  477. continue;
  478. else if(e==2)
  479. break;
  480. }
  481. system("cls");
  482. break;
  483.  
  484.  
  485. }
  486. case 9:
  487. {
  488. ex = 1;
  489. break;
  490. }
  491.  
  492. }
  493. }
  494. }
Advertisement
Add Comment
Please, Sign In to add comment