Advertisement
Guest User

dsd

a guest
Jun 20th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.23 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include<string.h>
  4.  
  5. struct student {
  6. char firstname[64], lastname[64], address[100] , email[32];
  7. long int mo_no, mis;
  8. int age ;
  9. char grade ;
  10. char DOB[20];
  11. }input, data[1000];
  12. /*
  13. В структурах только декларация и ничего больше. Структуры находятся вне функций, только в теле файла
  14.  
  15. */
  16. /*
  17. Указатели в си это переменные, которые хранят адреса ячеек памяти. &-амперсанд(унарная операция взятия адерса)
  18.  
  19. */
  20. struct acadmic{
  21. long int mis;
  22. int sub1;
  23. int sub2;
  24. int sub3;
  25. int sub4;
  26. int sub5;
  27. int sgpa;
  28. }input1,data1[1000];
  29.  
  30. int a,count1;
  31. float sgpa[1000];
  32. int count = 0;
  33.  
  34. void add() {
  35. printf("please enter your mis no:");
  36. scanf(" %ld", &input.mis);
  37. printf("please enter the full name\n");
  38. printf("first Name: ");
  39. scanf (" %s", input.firstname);
  40. printf("last Name: ");
  41. scanf (" %s", input.lastname);
  42. printf("address :");
  43. scanf("%s", input.address);
  44. printf("email:");
  45. scanf(" %s", input.email);
  46. printf("age : ");
  47. scanf (" %d", &input.age);
  48. printf("mo_no : ");
  49. scanf (" %ld", &input.mo_no);
  50. printf("enter the DOB in dd-mm-yy :");
  51. scanf("%s", input.DOB);
  52.  
  53. }
  54.  
  55. void addmarks(){
  56. int i;
  57. printf("\t\t you are in first year\n");
  58. printf("\t\t enter your mis no.");
  59. scanf("%ld", &input1.mis);
  60. printf("please enter the marks of Sub1 out of 100:");
  61. scanf("%d", &input1.sub1);
  62. printf("please enter the marks of Sub2 out of 100:");
  63. scanf("%d", &input1.sub2);
  64. printf("please enter the marks of Sub3 out of 100:");
  65. scanf("%d", &input1.sub3);
  66. printf("please enter the marks of Sub4 out of 100:");
  67. scanf("%d", &input1.sub4);
  68. printf("please enter the marks of Sub5 out of 100:");
  69. scanf("%d", &input1.sub5);
  70. }
  71.  
  72. void read(){
  73. g();
  74. int i = 0;
  75. printf("MISno. firstName lastname Address Email Age mobile no. Dateofbirth \n");
  76. FILE *fp;
  77. fp = fopen("student.txt", "a+");
  78. while(fscanf(fp, "%ld %s %s %s %s %d %ld %s \n", &data[i].mis, data[i].firstname, data[i].lastname,
  79. data[i].address, data[i].email, &data[i].age, &data[i].mo_no, data[i].DOB) != EOF) {
  80. printf("%10ld %8s %8s %8s %8s %4d %10ld %s\n", data[i].mis,data[i].firstname,data[i].lastname,
  81. data[i].address, data[i].email, data[i].age,data[i].mo_no, data[i].DOB);
  82. i++;
  83. }
  84. }
  85.  
  86. void read1(){
  87. float p;
  88. int i;
  89. SGPA();
  90. printf("MISNO. SUB1 SUB2 SUB3 SUB4 SUB5 SGPA\n");
  91. for(i=0;i<count1;i++){
  92. printf("%10ld %8d %8d %8d %8d %8d %f\n", data1[i].mis, data1[i].sub1,data1[i].sub2, data1[i].sub3, data1[i].sub4, data1[i].sub5, sgpa[i]);
  93. }
  94. }
  95.  
  96.  
  97. int g1(){
  98. int i=0;
  99. FILE *fp;
  100. if(a == 1 )
  101. fp = fopen ("firstyear.txt","a+");
  102. else if(a == 2)
  103. fp = fopen("secondyear.txt","a+");
  104.  
  105. else if(a == 3)
  106. fp = fopen ("thirdyear.txt","a+");
  107. else if(a == 4)
  108. fp = fopen("fouryear.txt","a+");
  109.  
  110.  
  111. while(fscanf(fp, "%ld %d %d %d %d %d\n", &data1[i].mis, &data1[i].sub1,&data1[i].sub2, &data1[i].sub3, &data1[i].sub4, &data1[i].sub5) != EOF) {
  112. i++;
  113. }
  114. count1 = i;
  115. }
  116.  
  117.  
  118. int g(){
  119. int i=0;
  120. FILE *fp;
  121. fp = fopen("student.txt", "a+");
  122. while(fscanf(fp, "%ld %s %s %s %s %d %ld %s \n",&data[i].mis, data[i].firstname,data[i].lastname, data[i].address, data[i].email, &data[i].age,&data[i].mo_no, data[i].DOB)!= EOF) {
  123. i++;
  124. }
  125. count = i;
  126. return count;
  127. }
  128. int f(){
  129. FILE *fp;
  130. fp = fopen ("student.txt","a+");
  131. if (fp == NULL){
  132. fprintf(stderr, "\nError opening student.txt\n\n");
  133. exit (1);
  134. }
  135. fprintf(fp,"%ld %s %s %s %s %d %ld %s \n ",input.mis,input.firstname,input.lastname,input.address,input.email,input.age,input.mo_no,input.DOB);
  136.  
  137. fclose(fp);
  138. }
  139.  
  140.  
  141. void f1(){
  142. FILE *fp;
  143. if(a == 1 )
  144. fp = fopen ("firstyear.txt","a+");
  145. else if(a == 2)
  146. fp = fopen("secondyear.txt","a+");
  147.  
  148. else if(a == 3)
  149. fp = fopen ("thirdyear.txt","a+");
  150. else
  151. fp = fopen("fouryear.txt","a+");
  152.  
  153. if (fp == NULL){
  154. fprintf(stderr, "\nError opening student.txt\n\n");
  155. exit (1);
  156. }
  157. fprintf(fp,"%ld %d %d %d %d %d \n",input1.mis,input1.sub1,input1.sub2,input1.sub3,input1.sub4,input1.sub5);
  158.  
  159. fclose(fp);
  160. }
  161. void modifymark(){
  162. int choice;
  163. char a[20];
  164. char y;
  165. long int q;
  166. int p,i,r,z=1;
  167. g1();
  168. printf("enter the mis of student :");
  169. while(r != 1) {
  170. scanf("%ld", &q);
  171. for(i = 0; i < count1; i++) {
  172. if(data1[i].mis == q) {
  173. r = 1;
  174. break;
  175. }
  176. }
  177. if( r != 1){
  178. printf("please enter the correct mis:");
  179. }
  180. }
  181. printf("\t\twhat do you want to change\n");
  182. printf("\t\t1.MIS Number\n\t\t2.sub1\n\t\t3.sub2\n\t\t4.sub3\n\t\t5.sub4\n\t\t6.sub5\n ");
  183.  
  184.  
  185. scanf("%d", &choice);
  186. switch(choice){
  187. case 1:
  188. printf("current mis is : %ld\n", data1[i].mis);
  189. printf("enter the new mis:");
  190. scanf("%ld", &q);
  191. data1[i].mis = q;
  192.  
  193. case 2:
  194. printf("the current marks in sub1 out of 100: %d\n", data1[i].sub1);
  195. printf("enter the new marks of sub1 out of 100: ");
  196. scanf("%d", &p);
  197. data1[i].sub1 = p ;
  198. break;
  199. case 3:
  200. printf("the current marks in sub2 out of 100: %d\n", data1[i].sub2);
  201. printf("enter the new marks of sub2 out of 100: ");
  202. scanf("%d", &p);
  203. data1[i].sub2 = p ;
  204. break;
  205. case 4:
  206. printf("the current marks in sub3 out of 100: %d\n", data1[i].sub3);
  207. printf("enter the new marks of sub3 out of 100: ");
  208. scanf("%d", &p);
  209. data1[i].sub3 = p ;
  210. break;
  211. case 5:
  212. printf("the current marks in sub4 out of 100: %d\n", data1[i].sub4);
  213. printf("enter the new marks of sub4 out of 100: ");
  214. scanf("%d", &p);
  215. data1[i].sub4 = p ;
  216. break;
  217.  
  218. case 6:
  219. printf("the current marks in sub5 out of 100: %d\n", data1[i].sub5);
  220. printf("enter the new marks of sub5 out of 100: ");
  221. scanf("%d", &p);
  222. data1[i].sub5 = p ;
  223. break;
  224. case 7:
  225. break;
  226.  
  227. }
  228. fileprint();
  229. }
  230.  
  231. // when file modification is done then reprint all data in the file
  232. int fileprint(){
  233. int i;
  234. FILE *fp;
  235. if(a == 1 )
  236. fp = fopen ("firstyear.txt","w");
  237. else if(a == 2)
  238. fp = fopen("secondyear.txt","w");
  239. else if(a == 3)
  240. fp = fopen ("thirdyear.txt","w");
  241. else
  242. fp = fopen("fouryear.txt","w");
  243. if (fp == NULL){
  244. fprintf(stderr, "\nError opening student.txt\n\n");
  245. exit (1);
  246. }
  247. for(i=0;i<count1;i++) {
  248. fprintf(fp,"%ld %d %d %d %d %d\n",data1[i].mis,data1[i].sub1,data1[i].sub2,data1[i].sub3, data1[i].sub4, data1[i].sub5);
  249. }
  250. fclose(fp);
  251. }
  252.  
  253. /* modifying the function in to array of structure */
  254. void modify(){
  255. int choice,r,z = 1;
  256. char a[20];
  257. char y;
  258. g();
  259. long int i=0, t, p, q;
  260. printf("enter the mis of student :");
  261. while(r != 1) {
  262. scanf("%ld", &q);
  263. for(i = 0; i < count; i++) {
  264. if(data[i].mis == q){ // comparing the mis with data
  265. r = 1;
  266. break;
  267. }
  268. }
  269. if( r != 1)
  270. printf("please enter the correct mis:");
  271. }
  272.  
  273. printf("\t\twhat do you want to change\n");
  274. printf("\t\t1.MIS Number\n");
  275. printf("\t\t2.first Name\n");
  276. printf("\t\t3.last name\n");
  277. printf("\t\t4.address\n");
  278. printf("\t\t5.email\n");
  279. printf("\t\t6.age\n");
  280. printf("\t\t7.mobile number\n");
  281. printf("\t\t8.date of birth\n");
  282. scanf("%d", &choice);
  283. switch(choice){
  284. case 1:
  285. printf("current mis is : %ld\n", data[i].mis);
  286. printf("enter the new mis:");
  287. scanf("%ld",&p);
  288. data[i].mis = p;
  289. break;
  290.  
  291. case 2:
  292. printf("the current first name is : %s\n", data[i].firstname);
  293. printf("enter the new first name : ");
  294. scanf("%s",a);
  295. strcpy(data[i].firstname,a) ;
  296. break;
  297. case 3:
  298. printf("the current last name is : %s\n", data[i].lastname);
  299. printf("enter the new last name : ");
  300. scanf("%s",a);
  301. strcpy(data[i].lastname,a) ;
  302. break;
  303.  
  304. case 4:
  305. printf("the current address is : %s\n", data[i].address);
  306. printf("enter the new address : ");
  307. scanf("%s", a);
  308. strcpy(data[i].address, a);
  309. break;
  310. case 5:
  311. printf("the current email address : %s\n", data[i].email);
  312. printf("enter the new email : ");
  313. scanf("%s", a);
  314. strcpy(data[i].email, a);
  315. break;
  316. case 6:
  317. printf("the current age is : %d\n", data[i].age);
  318. printf("enter the new age : ");
  319. scanf("%ld", &p);
  320. data[i].age = p;
  321. break;
  322. case 7:
  323. printf("the current mobile number is : %ld\n", data[i].mo_no);
  324. printf("enter the new mo_no : ");
  325. scanf("%ld", &p);
  326. data[i].mo_no = p;
  327. break;
  328. case 8:
  329. printf("the current Date of Birth is : %s\n", data[i].DOB);
  330. printf("enter the new Date of Birth : ");
  331. scanf("%s", a);
  332. strcpy(data[i].DOB , a) ;
  333. break;
  334. case 9:
  335. break;
  336.  
  337. }
  338. FILE *fp;
  339. fp = fopen ("student.txt","w");
  340. if (fp == NULL){
  341. fprintf(stderr, "\nError opening student.txt\n\n");
  342. exit (1);
  343. }
  344. for(i=0;i<count;i++){
  345. fprintf(fp,"%ld %s %s %s %s %d %ld %s\n", data[i].mis, data[i].firstname, data[i].lastname, data[i].address, data[i].email, data[i].age, data[i].mo_no, data[i].DOB);
  346. }
  347. fclose(fp);
  348. }
  349.  
  350. void delete(){
  351. char a[20];
  352. long int r;
  353. int p;
  354. int i,t;
  355. printf("enter the mis of the student :");
  356. scanf("%ld", &r);
  357. printf("please reconfirm that you want to delete information of %ld ",r);
  358. printf("press 1 for yes :" );
  359. scanf("%d", &p);
  360. if(p == 1){
  361. g();
  362. for(i=0; i < count; i++){
  363. if(data[i].mis == r){
  364. t = i;
  365. break;
  366. }
  367. }
  368. for (i = t; i < count; i++)
  369. data[i] = data[i+1];
  370. }
  371. else
  372. return;
  373.  
  374. FILE *fp;
  375. fp = fopen("student.txt","w");
  376. for(i = 0;i < count-1; i++){
  377. fprintf(fp,"%ld %s %s %s %s %d %ld %s\n", data[i].mis, data[i].firstname, data[i].lastname, data[i].address, data[i].email, data[i].age, data[i].mo_no, data[i].DOB);
  378. }
  379. fclose(fp);
  380. }
  381.  
  382. void record(){
  383.  
  384. int p,i,j=0,n,k;
  385. float cgpa = 0 ;
  386. printf("\t\t\tstudents information\n");
  387. i = search();
  388. n = selectyear();
  389. a = 0 ;
  390. for(a = 1 ; a < n+1; a++) {
  391. if(a == 1)
  392. printf("Your Marks in First Year\n");
  393. if(a == 2)
  394. printf("Your Marks in Second Year\n");
  395. if(a == 3)
  396. printf("Your Marks in third Year\n");
  397. if(a == 4)
  398. printf("Your Marks in Fourth Year\n");
  399. g1();
  400. SGPA();
  401. if(data[i].mis = data1[j].mis)
  402. p = j;
  403. else
  404. j++;
  405. printf("-------------------------------------------------------------------------------------------\n");
  406. printf("\t\tstudents acadamic information \n ");
  407. printf("\t\t\tmarks of sub1 = %d \n", data1[p].sub1);
  408. printf("\t\t\tmarks of sub2 = %d \n", data1[p].sub2);
  409. printf("\t\t\tmarks of sub3 = %d \n", data1[p].sub3);
  410. printf("\t\t\tmarks of sub4 = %d \n", data1[p].sub4);
  411. printf("\t\t\tmarks of sub5 = %d \n", data1[p].sub5);
  412. printf("\t\t\t your sgpa is = %f\n", sgpa[p]);
  413. cgpa = cgpa + sgpa[p];
  414. if(a != 1)
  415. cgpa = cgpa/2;
  416. printf("\t\t\tYour CGPA IS = %f\n",cgpa);
  417. printf("-------------------------------------------------------------------------------------------\n");
  418. }
  419. }
  420.  
  421. void delete1(){
  422. long int y;
  423. char a[20];
  424. int p,x;
  425. int i,r;
  426. g();
  427. printf("enter the MIS of the student :");
  428. while(r != 1) {
  429. scanf("%ld",&y);
  430. for(i = 0; i < count1; i++) {
  431. if(data1[i].mis== y){
  432. x = i;
  433. r = 1;
  434. break;
  435. }
  436. }
  437. if( r != 1)
  438. printf("please enter the correct mis:");
  439.  
  440. }
  441. for (i = x; i < count1-1; i++)
  442. data1[i] = data1[i+1];
  443.  
  444. count1 = count1-1;
  445. fileprint();
  446. }
  447.  
  448.  
  449. int search(){
  450. long int q ,r = 0;
  451. char a[20];
  452. printf("enter the mis of the student :");
  453. int i;
  454. g();
  455. while(r != 1) {
  456. scanf("%ld",&q);
  457. for(i = 0; i < count; i++) {
  458. if(data[i].mis == q) {
  459. r = 1;
  460. break;
  461. }
  462. }
  463. if( r != 1)
  464. printf("please enter the correct mis:");
  465. }
  466. printf("\t\t students personal information\n");
  467. printf("-------------------------------------------------------------------------------------------\n");
  468. printf("\t\t\tMIS no:- %ld\n", data[i].mis);
  469. printf("\t\t\tName = %s %s \n", data[i].firstname, data[i].lastname);
  470. printf("\t\t\tAddress = %s\n", data[i].address);
  471. printf("\t\t\tEmail = %s\n", data[i].email);
  472. printf("\t\t\tAge = %d\n", data[i].age);
  473. printf("\t\t\tmo_no = %ld\n", data[i].mo_no);
  474. printf("\t\t\tDate of Birth = %s\n", data[i].DOB);
  475. r = i;
  476. printf("-------------------------------------------------------------------------------------------\n");
  477. return i;
  478. }
  479.  
  480. void search1(){
  481. long int q, r;
  482. printf("enter the mis of the student :");
  483. int i;
  484. g1();
  485. while(r!=1) {
  486. scanf("%ld",&q);
  487. for(i = 0; i < count1; i++) {
  488. if(data1[i].mis== q) {
  489. r=1;
  490. break;
  491. }
  492. }
  493. if( r!=1)
  494. printf("please enter the correct mis:\n");
  495. }
  496. printf("-------------------------------------------------------------------------------------------\n");
  497. printf("\t\t\tMIS no:- %ld\n",data1[i].mis);
  498. printf("\t\t\tmarks of sub1 out of 100 = %d \n",data1[i].sub1);
  499. printf("\t\t\tmarks of sub2 out of 100 = %d \n",data1[i].sub2);
  500. printf("\t\t\tmarks of sub3 out of 100 = %d \n",data1[i].sub3);
  501. printf("\t\t\tmarks of sub4 out of 100 = %d \n",data1[i].sub4);
  502. printf("\t\t\tmarks of sub5 out of 100 = %d \n",data1[i].sub5);
  503. printf("\t\t\tsgpa is out of 10 = %f\n",sgpa[i]);
  504. printf("-------------------------------------------------------------------------------------------\n");
  505. }
  506.  
  507. void merge(struct student p[], int l, int m, int h){
  508. struct student b[1000];
  509. int i = l, k = 0, t = 0;
  510. int j = m + 1;
  511. while(i <= m && j <= h) {
  512. if(p[i].mis < p[j].mis)
  513. b[k++] = p[i++];
  514. else
  515. b[k++] = p[j++];
  516. }
  517. if(i > m)
  518. while(j <=h)
  519. b[k++] = p[j++];
  520. else
  521. while(i <=m)
  522. b[k++] = p[i++];
  523.  
  524. while(t < k) {
  525. p[l + t] = b[t];
  526. t++;
  527. }
  528.  
  529. }
  530.  
  531. void mergesort(struct student p[], int l, int h) {
  532. int m;
  533. if(l == h)
  534. return;
  535. m = (l + h)/2;
  536. mergesort(p, l, m);
  537. mergesort(p, m + 1, h);
  538. merge(p, l, m, h );
  539. }
  540.  
  541. void sort(struct student p[], int n) {
  542. int i;
  543. mergesort(p, 0, n-1);
  544. for(i = 0; i < count; i++){
  545. printf("%ld %s %s %s %s %d %ld %s\n", p[i].mis,p[i].firstname,p[i].lastname,p[i].address,p[i].email,p[i].age,p[i].mo_no,p[i].DOB);
  546. }
  547. }
  548. void merge1(struct acadmic p[], int l, int m, int h) {
  549. struct acadmic b[1000];
  550. int i = l, k = 0, t = 0;
  551. int j = m + 1;
  552. while(i <= m && j <= h) {
  553. if(p[i].mis < p[j].mis)
  554. b[k++] = p[i++];
  555. else
  556. b[k++] = p[j++];
  557. }
  558. if(i > m)
  559. while(j <=h)
  560. b[k++] = p[j++];
  561. else
  562. while(i <=m)
  563. b[k++] = p[i++];
  564.  
  565. while(t < k) {
  566. p[l + t] = b[t];
  567. t++;
  568. }
  569.  
  570. }
  571.  
  572. void mergesort1(struct acadmic p[], int l, int h) {
  573. int m;
  574. if(l == h)
  575. return;
  576. m = (l + h)/2;
  577. mergesort1(p, l, m);
  578. mergesort1(p, m + 1, h);
  579. merge1(p, l, m, h );
  580. }
  581.  
  582. void sort1(struct acadmic p[], int n) {
  583. int i;
  584. mergesort1(p, 0, n-1);
  585. printf("MISNO. SUB1 Sub2 SUB3 SUB4 SUB5\n");
  586. for(i = 0; i < count1; i++){
  587. printf("%ld %d %d %d %d %d\n", p[i].mis, p[i].sub1, p[i].sub2, p[i].sub3, p[i].sub4, p[i].sub5);
  588. }
  589. }
  590. void login(){
  591. int i,q=1;
  592. char p[16];
  593.  
  594. printf("\t\t WELCOME IN STUDENT DATABASE!!\n");
  595. printf("\t\t your are students or admistration \n");
  596. printf("\t\t please presss 1 for admin and press 2 for student and please press 3 for new registration\n");
  597. scanf("%d",&i);
  598. while(i == 1){
  599. printf("please enter your password:");
  600. scanf("%s",p);
  601. if(strcmp(p,"123456")==0){
  602. printf("\n\t\tWELCOME ADMIN!!\n");
  603. i=0;
  604. }
  605. else{
  606. printf("\n\t\tpassword incorrect!");
  607. printf("\n\t\tplease enter the corret password:\n");
  608. i=1;
  609. }
  610. }
  611. while(i==2){
  612. printf("\t\twelcome in collage database!!\n");
  613. printf("\n\t\tplease enter your password:");
  614. scanf("%s",p);
  615. if(strcmp(p,"student") == 0){
  616. while(q ==1 ){
  617. printf ("for read all data press 1 and 2 for search record:\n");
  618. scanf("%d",&q);
  619. if(q == 1){
  620. g();
  621. read();
  622. }
  623. if(q == 2){
  624. g();
  625. g1();
  626. record();
  627. }
  628. printf("do you want to continue press 1 \n ");
  629. scanf("%d",&q);
  630. }
  631. exit(0);
  632. }
  633. else{
  634. printf("\t\tpassword incorrect!\n\n");
  635. printf("\t\tplease enter the corret password!\n");
  636. }
  637. }
  638. }
  639. int selectyear(){
  640. printf("\t\tSELECT YOUR YEAR\n");
  641. printf("\t\t1.FIRST YEAR\n");
  642. printf("\t\t2.SECOND YEAR\n");
  643. printf("\t\t3.THIRD YEAR\n");
  644. printf("\t\t4.FOURTH YEAR\n");
  645. printf("\t\t5.exit\n");
  646. scanf("%d",&a);
  647. return a;
  648. }
  649. int printmenu(){
  650. int choice;
  651. printf("\n\t\t Choose from the following options\n\n");
  652. printf("\t\t\t 1.ADD PERSONAL INFORMATION \n\t\t\t 2.LIST PERSONAL INFORMATION \n\t\t\t 3.MODIFY PERSONAL INFORMATION \n\t\t\t 4.SORT PERSONAL INFORMATION \n\t\t\t 5.DELETE PERSONAL INFORMATION \n\t\t\t 6.SEARCH PERSONAL INFORMATION \n\t\t\t7.exit\n\n\t\t\t Your Choice: ");
  653. scanf("%d",&choice);
  654. return choice;
  655. }
  656. int printmenu1(){
  657. int choice;
  658. printf("\n\t\t Choose from the following options\n\n");
  659. printf("\t\t\t 1.ADD ACADMIC INFORMATION \n\t\t\t 2.LIST ACADMIC INFORMATION \n\t\t\t 3.MODIFY ACADMIC INFORMATION \n\t\t\t 4.SORT ACADMIC INFORMATION \n\t\t\t 5.DELETE ACADMIC INFORMATION \n\t\t\t 6.SEARCH ACADMIC INFORMATION \n\t\t\t7.exit\n\n\t\t\t Your Choice: ");
  660. scanf("%d",&choice);
  661. return choice;
  662. }
  663. int SGPA(){
  664. int i,k=0,m;
  665. g1();
  666. int j[5],l[5];
  667. float p,n;
  668. for(i=0;i<count1;i++) {
  669. m=0;
  670. j[0] = data1[i].sub1;
  671. j[1] = data1[i].sub2;
  672. j[2] = data1[i].sub3;
  673. j[3] = data1[i].sub4;
  674. j[4] = data1[i].sub5;
  675. for(k=0;k<5;k++){
  676. if (j[k]>=91 && j[k]<= 100 )
  677. l[m] = 10;
  678. else if (j[k]>=81 && j[k]<= 90)
  679. l[m] = 9;
  680. else if (j[k]>=71 && j[k]<= 80)
  681. l[m] = 8;
  682. else if (j[k]>=61 && j[k]<= 70)
  683. l[m] = 7;
  684. else if (j[k]>=51 && j[k]<= 60)
  685. l[m] = 6;
  686. else if (j[k]>=41 && j[k]<= 50)
  687. l[m] = 5;
  688. else if (j[k]>=31 && j[k]<= 40)
  689. l[m] = 4;
  690. else if (j[k]>=21 && j[k]<= 30)
  691. l[m] = 3;
  692. else if (j[k]>=11 && j[k]<= 20)
  693. l[m] = 2;
  694. else if (j[k]>=1 && j[k]<= 10)
  695. l[m] = 1;
  696. m++;
  697. }
  698. /* here we conside credits for sub1 = 3 , for sub2 = 3 , for sub3 = 4 ,for sub4 = 4, for sub5 = 5 */
  699. p = l[0] * 3 + l[1] * 3 + l[2] * 4 + l[3] * 4 + l[4] * 3 ;
  700. sgpa[i] = p/17;
  701. }
  702. }
  703. void main(){
  704. login();
  705. count = 0;
  706. g();
  707. g1();
  708. int choice;
  709. int ch=1 ,c;
  710. int n = count , x,i;
  711. printf("if you want to see whole record of any student please press 1 = ");
  712. scanf("%d",&i);
  713. if(i==1)
  714. record();
  715. while (ch ==1){
  716. printf("\nplease for accessing student information press 1 and accessing students mark press anything number:");
  717. scanf("%d",&x);
  718. if(x == 1){
  719. choice = printmenu();
  720. switch(choice){
  721. case 1:
  722. add();
  723. f();
  724. break;
  725.  
  726. case 2:
  727. read();
  728. break;
  729. case 3:
  730.  
  731. modify();
  732. break;
  733. case 4 :
  734. g();
  735. sort(data,n);
  736. break;
  737. case 5 :
  738. delete();
  739. break;
  740. case 6 :
  741. search();
  742. break;
  743. case 7 :
  744. exit(0);
  745. default:
  746. printf("inavalid input\n");
  747. break ;
  748. }
  749. }
  750. else {
  751. selectyear();
  752. choice = printmenu1();
  753. switch(choice){
  754. case 1:
  755. addmarks();
  756. f1();
  757. break;
  758. case 2:
  759. read1();
  760. break;
  761. case 3:
  762. modifymark();
  763. break;
  764. case 4:
  765. g1();
  766. sort1(data1,count1);
  767. break;
  768. case 5:
  769. delete1();
  770. break;
  771. case 6:
  772. search1();
  773. break;
  774. case 7:
  775. exit(0);
  776. default:
  777. printf("inavalid input\n");
  778. break ;
  779. }
  780. }
  781. printf("do you want to continue press 1 :");
  782. scanf("%d",&ch);
  783. }
  784. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement