Advertisement
asiffff

Untitled

Mar 28th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.94 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;
  213. while(1)
  214. {
  215. printf("1.Enter Student Details.\n2.View All Student Details\n3.Search Student Details.\n");
  216. printf("4.Enter Teacher Details.\n5.View All Teacher Details\n6.Search Teacher Details.\n");
  217. scanf("%d",&x);
  218. switch(x)
  219. {
  220. case 1:
  221. {
  222. while(1)
  223. {
  224. system("cls");
  225. create();
  226. printf("Do you want to continue?\n");
  227. printf("1.Yes 2.No\n");
  228. int e;
  229. scanf("%d",&e);
  230. if(e==1) continue;
  231. else break;
  232. }
  233. system("cls");
  234. break;
  235. }
  236. case 2:
  237. {
  238. system("cls");
  239. dis();
  240. printf("Press any key to quit.");
  241. getch();
  242. system("cls");
  243. break;
  244. }
  245. case 3:
  246. {
  247. while(1)
  248. {
  249. system("cls");
  250. int x1,y1;
  251. printf("Enter Class: ");
  252. scanf("%d",&x1);
  253. printf("\nEnter Student ID: ");
  254. scanf("%d",&y1);
  255. system("cls");
  256. int pos = search(x1,y1);
  257. if(pos==-1)
  258. {
  259. printf("Not Found");
  260. getch();
  261. system("cls");
  262. }
  263. else
  264. {
  265. struct student *b;
  266. b=start;
  267. int j;
  268. for(j=0; j<pos-1; j++)
  269. {
  270. b=b->next;
  271. }
  272. 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);
  273. printf("Press any key.");
  274. getch();
  275. system("cls");
  276. }
  277. printf("Do you want to search another?\n 1.Yes 2.No\n");
  278. int e;
  279. scanf("%d",&e);
  280. if(e==1) continue;
  281. else if(e==2) break;
  282.  
  283. }
  284. system("cls");
  285. break;
  286. }
  287. case 4:
  288. {
  289. while(1)
  290. {
  291. system("cls");
  292. create1();
  293. int e;
  294. printf("Do you want to Continue?\n1.Yes 2.No\n");
  295. scanf("%d",&e);
  296. if(e==1) continue;
  297. else if(e==2) break;
  298. }
  299. system("cls");
  300. break;
  301. }
  302. case 5:
  303. {
  304. dis1();
  305. getch();
  306. system("cls");
  307. break;
  308. }
  309. case 6:
  310. {
  311. printf("Enter Id:\n");
  312. int k;
  313. scanf("%d",&k);
  314. int pos1 = search(k,0);
  315. if(pos1==-1)
  316. {
  317. printf("\n Not Found\n");
  318. }
  319. else
  320. {
  321. struct teacher *c;
  322. c=start1;
  323. int j;
  324. for(j=0; j<pos1-1; j++)
  325. {
  326. c=c->next;
  327. }
  328. printf("\nTeacher ID:%d\n",c->id);
  329. printf("Your group:%s\n",c->group);
  330. printf("Teacher Name:%s\n",c->name);
  331. printf("Teacher Gender:%s\n",c->gender);
  332. printf("Teacher Phone number:%ld\n",c->phnum);
  333. getch();
  334. system("cls");
  335.  
  336. }
  337. break;
  338. }
  339. case 7:
  340. {
  341. int x1,y1;
  342. printf("Enter Class: ");
  343. scanf("%d",&x1);
  344. printf("Enter Student ID: ");
  345. scanf("%d",&y1);
  346. int k;
  347. //y=2;
  348. int pos1 = search(x1,y1);
  349. if(pos1==-1)
  350. {
  351. printf("\n Not Found\n");
  352. }
  353. else
  354. {
  355. struct student *c;
  356. c=start;
  357. int j;
  358. for(j=0; j<pos1-1; j++)
  359. {
  360. c=c->next;
  361. }
  362. printf("Bangla :\n");
  363. scanf("%lf",&c->bangla);
  364. printf("English:\n");
  365. scanf("%lf",&c->english);
  366. printf("Math:\n");
  367. scanf("%lf",&c->math);
  368. printf("Physics:\n");
  369. scanf("%lf",&c->physics);
  370. printf("Chemistry:\n");
  371. scanf("%lf",&c->chemistry);
  372. printf("Biology:\n");
  373. scanf("%lf",&c->biology);
  374. //getch();
  375. system("cls");
  376.  
  377. }
  378. break;
  379. }
  380. case 8:
  381. {
  382. int x1,y1;
  383. printf("Enter Class: ");
  384. scanf("%d",&x1);
  385. printf("Enter Student ID: ");
  386. scanf("%d",&y1);
  387. int k;
  388. //y=2;
  389. int pos1 = search(x1,y1);
  390. if(pos1==-1)
  391. {
  392. printf("\n Not Found\n");
  393. }
  394. else
  395. {
  396. struct student *c;
  397. c=start;
  398. int j;
  399. for(j=0; j<pos1-1; j++)
  400. {
  401. c=c->next;
  402. }
  403. printf("Bangla : %.2lf\n",c->bangla);
  404. //scanf("%lf",&c->bangla);
  405. printf("English: %.2lf\n",c->english);
  406. //scanf("%lf",&c->english);
  407. printf("Math: %.2lf\n",c->math);
  408. //scanf("%lf",&c->math);
  409. printf("Physics: %.2lf\n",c->physics);
  410. //scanf("%lf",&c->physics);
  411. printf("Chemistry: %.2lf\n",c->chemistry);
  412. //scanf("%lf",&c->chemistry);
  413. printf("Biology: %.2lf\n",c->biology);
  414. //scanf("%lf",c->biology);
  415. getch();
  416. system("cls");
  417.  
  418. }
  419.  
  420.  
  421. }
  422.  
  423. }
  424. }
  425. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement