Here you will find the complete tutorial on Student Information System Using C. This software has various feature as listed below.
Note: You are free to use, edit, update and rebuild the program source codes downloaded from here. Please don’t forget to give considerable credits to Dreamlover Technology and bestengineeringprojects.com if you do so.
Project Features:
- Password Protection
- Add record
- List Record
- Search Record
- Modify Record
- Delete Record.
Student Information System will not be reliable and perfect enough to implement it in a real working environment, but this project is very helpful to build a basic experience on file handling using “C”. And you can also certainly expand and enhance the Student Information System program to make it implementable in the real field.
So, let’s get started!
If you already know enough about FILE and structure and can program easily using C in DEV C++, then you can directly download dev C++ IDE, start a new project, copy the code given below and compile the project.
Preparation for the program:
So to get started, here are a few steps you need to follow:
- First of all, download the latest version of DEV C++ from its official site and install it in your system.
- Now open the DEV C++.
- Click on: File>New>Project>Empty project.
- Choose a path where you would like to save your project and give your project a name (Student Information System, say).
- Now click on File>New>Source file.
Now you are ready to code!
You can just simply paste the following code in the source file, compile and execute it.
The Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 |
/* Name: Student Information System Copyright: http://bestengineeringprojects.com Author: BEP Date: 24/1/15 23:39 */ #include<stdio.h> #include<stdlib.h> #include<string.h> #include<ctype.h> #include<conio.h> /* function deslaration start*/ void add(); void display(); void search_modify(); void delete(); void input(); void output(); void division1(); void division2(); void division3(); void division4(); /*Function declaration End*/ FILE *BEX,*BCT,*CIVIL; //file pointer typedef struct { char f_name[25],l_name[25],address[100],phone_no[15],bloodgroup[5],section; char roll[15]; float marks[6],obt_marks,avg_marks,total_marks[6],percent; }student; student st; //global declaration of structure int main() //main function start { int c=1; char password[10]; char pass[]={"123"}; printf("\t\t\twww.bestengineeringprojects.com"); printf("\n\n\t\tplease enter the password:> "); gets(password); if(strcmp(password,pass)==0) /*Password Compare*/ { start: system("cls"); int no; do { system("cls"); height: printf("\t\t====== STUDENT INFORMATION SYSTEM ======"); /*Menu*/ printf("\n\n "); printf( "\n\n"); printf( "\n \t\t\t 1. Add Records"); printf( "\n \t\t\t 2. List Records"); printf( "\n \t\t\t 3. Search and Modify Records"); printf( "\n \t\t\t 4. Delete Records"); printf( "\n \t\t\t 5. Exit Program"); printf( "\n\n"); printf("\t\t\t Select Your Choice(1,2,3,4 or 5) :=> "); target : scanf("%d",&no); switch(no) { case 1: add(); /* Add Function Calling*/ break; case 2: display(); /*Display Function Calling*/ break; case 3: search_modify(); /*Search_ modify Function Calling*/ break; case 4: delete(); /*Delete Function Calling*/ break; case 5: /*Program exit with leaving this message*/ printf( "\n\n"); printf("\t\t THANK YOU FOR USING THIS SOFTWARE"); printf( "\n\n"); getch(); exit(0); "\n\n"; break; default : printf("\n\t\tInvalid choice--please enter the valid choice again:"); goto target; break; } }while(no!=5); } else { while(1) /*Second time password comparing*/ { if(c==1) printf("\n\t\tincorrect password??? last 2 try left"); printf("\n\t\tenter the correct password again "); gets(password); if(strcmp(password,pass)==0) { goto start; } else if(strcmp(password,pass)!=0) /*Last time password comparing*/ { c=c++; if(c==2) printf("\n\t\tinvalid password??? last time"); if(c==3) exit(0); } } } return 0; } //end of main function void add() //start of add function { system("cls"); int ch,no; char ans; printf("\n\n\n"); //add menu printf( "\n \t\t\t 1. add record in electronics faculty"); printf( "\n \t\t\t 2. add record in computer faculty"); printf( "\n \t\t\t 3. add record in civil faculty"); printf( "\n \t\t\t 4. return to main menu"); printf( "\n\n"); printf("\t\t\t Select Your Choice(1,2,3 or 4) :=> "); top:scanf("%d",&ch); switch(ch) { case 1: system("cls"); //for electronics file BEX=fopen("D:\\electronics.txt","ab"); if(BEX==NULL) { printf("error in opening electronics.txt file"); getch(); exit(0); } do { input(); fwrite(&st,sizeof(st),1,BEX); printf("do you want to add another record (y for yes)"); fflush(stdin); scanf("%c",&ans); }while(tolower(ans)=='y'); fclose(BEX); break; case 2: system("cls"); BCT=fopen("D:\\computer.txt","ab"); //for computer file if(BCT==NULL) { printf("error in opening computer.txt file"); getch(); exit(0); } do { input(); fwrite(&st,sizeof(st),1,BCT); printf("do you want to add another record (y for yes)"); fflush(stdin); scanf("%c",&ans); }while(tolower(ans)=='y'); fclose(BCT); break; case 3: system("cls"); // for civil file CIVIL=fopen("D:\\civil.txt","ab"); if(CIVIL==NULL) { printf("error in opening computer.txt file"); getch(); exit(0); } do { input(); fwrite(&st,sizeof(st),1,CIVIL); printf("do you want to add another record (y for yes)"); fflush(stdin); scanf("%c",&ans); }while(tolower(ans)=='y'); fclose(CIVIL); break; case 4: break; default : printf("\t\tenter the valid choice"); goto top; break; } } //end of add function void input() //start of input function { int z; for(z=0;z<6;z++) { st.total_marks[z]=0; st.marks[z]=0; } int i; float sum=0,total=0; char ans; printf("\tplease enter the first name:>"); fflush(stdin); gets(st.f_name); //name,roll no,section printf("\tplease enter the last name:>"); fflush(stdin); gets(st.l_name); printf("\tplease enter the section:>"); fflush(stdin); scanf("%c",&st.section); printf("\tplease enter the roll number:>"); scanf("%s",st.roll); printf("do u want to add marks(y for yes)"); fflush(stdin); scanf("%c",&ans); for(i=0;i<1;i++) { if(tolower(ans)!='y') break; //input of marks printf("enter the total marks & marks obtained in Computer:>"); scanf("%f%f",&st.total_marks[i],&st.marks[i]); i=i+1; printf("enter the total marks & marks obtained in Physics:>"); scanf("%f%f",&st.total_marks[i],&st.marks[i]); i=i+1; printf("enter the total marks & marks obtained in Applied Mechanics:>"); scanf("%f%f",&st.total_marks[i],&st.marks[i]); i=i+1; printf("enter the total marks & marks obtained in Mathematics:>"); scanf("%f%f",&st.total_marks[i],&st.marks[i]); i=i+1; printf("enter the total marks & marks obtained in Basic Electrical:>"); scanf("%f%f",&st.total_marks[i],&st.marks[i]); i=i+1; printf("enter the total marks & marks obtained in Drawing:>"); scanf("%f%f",&st.total_marks[i],&st.marks[i]); i=i+1; } if(i!=0) { for(i=0;i<6;i++) { //calculation of percent,average and obtained marks sum+=st.marks[i]; total+=st.total_marks[i]; } st.obt_marks=sum; st.avg_marks=sum/6; st.percent=(sum/total)*100; } printf("please enter the phone number:>"); //phone number fflush(stdin); gets(st.phone_no); printf("please enter the address:>"); //address fflush(stdin); gets(st.address); printf("\tplease enter the blood group:>"); //blood group fflush(stdin); gets(st.bloodgroup); } int dist,frist,sec,pass; //end of input function void display() //start of display function { int no,fail,ch; char blood[5]; system("cls"); reverse: printf("\n\n\n\n"); printf("\n\t\t\t1.list all"); printf("\n\t\t\t2.list of Electronics faculty"); printf("\n\t\t\t3.list of Computer faculty"); printf("\n\t\t\t4.list of Civil faculty"); printf("\n\t\t\t5.list of passed student"); printf("\n\t\t\t6.list of failed student"); printf("\n\t\t\t7.list of student by blood group"); printf("\n\t\t\t8.return to main menu"); printf("\n\n\t\t\tenter the choice your choice from(1-8)=>"); upper: scanf("%d",&no); switch(no) { case 1: system("cls"); //for electronics file BEX=fopen("D:\\electronics.txt","rb"); if(BEX==NULL) { printf("\n\n\t\terror in opening electronics.txt file\n"); // getch(); // exit(0); } else { printf("\n\n\t\tfaculty \"BEX\""); while(fread(&st,sizeof(st),1,BEX)==1) { output(); } } BCT=fopen("D:\\computer.txt","rb"); if(BCT==NULL) { printf("\n\n\t\terror in opening computer.txt file\n"); // getch(); // exit(0); } else { printf("\n\t\t\tfaculty \"BCT\""); while(fread(&st,sizeof(st),1,BCT)==1) { output(); } } CIVIL=fopen("D:\\civil.txt","rb"); if(CIVIL==NULL) { printf("\n\n\t\terror in opening civil.txt file"); getch(); break; // exit(0); } printf("\n\t\t\tfaculty \"CIVIL\""); while(fread(&st,sizeof(st),1,CIVIL)==1) { output(); } getch(); fclose(BEX); fclose(BCT); fclose(CIVIL); break; case 2: system("cls"); //for electronics file BEX=fopen("D:\\electronics.txt","rb"); if(BEX==NULL) { printf("\n\n\t\terror in opening electronics.txt file"); getch(); break; // exit(0); } printf("faculty \"BEX\""); // rewind(BEX); while(fread(&st,sizeof(st),1,BEX)==1) { output(); } getch(); fclose(BEX); break; case 3: system("cls"); BCT=fopen("D:\\computer.txt","rb"); if(BCT==NULL) { printf("\n\n\t\terror in opening computer.txt file"); getch(); break; // exit(0); } printf("faculty \"BCT\""); // rewind(BCT); while(fread(&st,sizeof(st),1,BCT)==1) { output(); } getch(); fclose(BCT); break; case 4: system("cls"); CIVIL=fopen("D:\\civil.txt","rb"); if(CIVIL==NULL) { printf("\n\n\t\terror in opening civil.txt file"); getch(); break; // exit(0); } printf("faculty \"CIVIL\""); // rewind(CIVIL); while(fread(&st,sizeof(st),1,CIVIL)==1) { output(); } getch(); fclose(CIVIL); break; case 5: system("cls"); printf("enter the distiction percent="); scanf("%d",&dist); printf("enter the frist division percent="); scanf("%d",&frist); printf("enter the second division percent="); scanf("%d",&sec); printf("enter the passed division percent="); scanf("%d",&pass); system("cls"); printf("\n\n"); printf("\n\t\t500.all student"); printf("\n\t\t600.electronics student"); printf("\n\t\t700.computer student"); printf("\n\t\t800.civil student"); printf("\n\t\t900.return to menu"); printf("\n\n\t\t\tenter the choice(500,600,700,800,900)=>"); above: scanf("%d",&ch); switch(ch) { case 500: system("cls"); BEX=fopen("D:\\electronics.txt","rb"); if(BEX==NULL) { printf("\n\n\t\terror in opening electronics.txt file\n\n"); } else { while(fread(&st,sizeof(st),1,BEX)==1) { division1(); } rewind(BEX); while(fread(&st,sizeof(st),1,BEX)==1) { division2(); } rewind(BEX); while(fread(&st,sizeof(st),1,BEX)==1) { division3(); } rewind(BEX); while(fread(&st,sizeof(st),1,BEX)==1) { division4(); } fclose(BEX); } BCT=fopen("D:\\computer.txt","rb"); if(BCT==NULL) { printf("\n\n\t\terror in opening computer.txt file\n\n"); } else { while(fread(&st,sizeof(st),1,BCT)==1) { division1(); } rewind(BCT); while(fread(&st,sizeof(st),1,BCT)==1) { division2(); } rewind(BCT); while(fread(&st,sizeof(st),1,BCT)==1) { division3(); } rewind(BCT); while(fread(&st,sizeof(st),1,BCT)==1) { division4(); } fclose(BCT); } CIVIL=fopen("D:\\civil.txt","rb"); if(CIVIL==NULL) { printf("\n\n\t\terror in opening civil.txt file"); getch(); break; // exit(0); } while(fread(&st,sizeof(st),1,CIVIL)==1) division1(); rewind(CIVIL); while(fread(&st,sizeof(st),1,CIVIL)==1) division2(); rewind(CIVIL); while(fread(&st,sizeof(st),1,CIVIL)==1) division3(); rewind(CIVIL); while(fread(&st,sizeof(st),1,CIVIL)==1) division4(); getch(); fclose(CIVIL); break; case 600: system("cls"); BEX=fopen("D:\\electronics.txt","rb"); if(BEX==NULL) { printf("\n\t\t\terror in opening electronics.txt file"); getch(); break; } while(fread(&st,sizeof(st),1,BEX)==1) division1(); rewind(BEX); while(fread(&st,sizeof(st),1,BEX)==1) division2(); rewind(BEX); while(fread(&st,sizeof(st),1,BEX)==1) division3(); rewind(BEX); while(fread(&st,sizeof(st),1,BEX)==1) division4(); fclose(BEX); getch(); break; case 700: system("cls"); BCT=fopen("D:\\computer.txt","rb"); if(BCT==NULL) { printf("\n\n\t\terror in opening computer.txt file"); getch(); break; } while(fread(&st,sizeof(st),1,BCT)==1) { division1(); } rewind(BCT); while(fread(&st,sizeof(st),1,BCT)==1) { division2(); } rewind(BCT); while(fread(&st,sizeof(st),1,BCT)==1) { division3(); } rewind(BCT); while(fread(&st,sizeof(st),1,BCT)==1) { division4(); } getch(); fclose(BCT); break; case 800: system("cls"); CIVIL=fopen("D:\\civil.txt","rb"); if(CIVIL==NULL) { printf("\n\n\t\terror in opening civil.txt file"); getch(); break; } while(fread(&st,sizeof(st),1,CIVIL)==1) division1(); rewind(CIVIL); while(fread(&st,sizeof(st),1,CIVIL)==1) division2(); rewind(CIVIL); while(fread(&st,sizeof(st),1,CIVIL)==1) division3(); rewind(CIVIL); while(fread(&st,sizeof(st),1,CIVIL)==1) division4(); getch(); fclose(CIVIL); break; case 900: system("cls"); goto reverse; break; default : printf("enter the valid choice"); goto above; break; } break; case 6: system("cls"); printf("enter the fail percent"); scanf("%d",&fail); BEX=fopen("D:\\electronics.txt","rb"); if(BEX==NULL) { printf("\n\t\t\terror in opening electronics.txt file"); getch(); break; } while(fread(&st,sizeof(st),1,BEX)==1) { if(st.percent<=fail) { printf("\nName=%s %s",st.f_name,st.l_name); printf("\nRoll number=%s",st.roll); printf("\nSection=%c",st.section); printf("\nBlood group=%s",st.bloodgroup); printf("\nPhone no=%s",st.phone_no); printf("\nAddress=%s",st.address); printf("\n\n \t\tMarks obtained in each subject are:>\n"); printf("Subject \t\ttotal marks\tobt marks\t\n\n"); printf("Computer= \t\t%.2f\t\t%.2f\n",st.total_marks[0],st.marks[0]); printf("physics= \t\t%.2f\t\t%.2f\n",st.total_marks[1],st.marks[1]); printf("Mechanics= \t\t%.2f\t\t%.2f\n",st.total_marks[2],st.marks[2]); printf("Mathematics=\t\t%.2f\t\t%.2f\n",st.total_marks[3],st.marks[3]); printf("Electrical= \t\t%.2f\t\t%.2f\n",st.total_marks[4],st.marks[4]); printf("Drawing= \t\t%.2f\t\t%.2f\n",st.total_marks[5],st.marks[5]); printf("\n\ntotal obtained marks=%f",st.obt_marks); printf("\nAverage marks=%f",st.avg_marks); printf("\nPercentage=%f\n",st.percent); printf("\n\t------------------------------\n\n\n\n"); } } BCT=fopen("D:\\computer.txt","rb"); if(BCT==NULL) { printf("\n\n\t\terror in opening computer.txt file"); getch(); break; } while(fread(&st,sizeof(st),1,BCT)==1) { if(st.percent<=fail) { printf("\nName=%s %s",st.f_name,st.l_name); printf("\nRoll number=%s",st.roll); printf("\nSection=%c",st.section); printf("\nBlood group=%s",st.bloodgroup); printf("\nPhone no=%s",st.phone_no); printf("\nAddress=%s",st.address); printf("\n\n \t\tMarks obtained in each subject are:>\n"); printf("Subject \t\ttotal marks\tobt marks\t\n\n"); printf("Computer= \t\t%.2f\t\t%.2f\n",st.total_marks[0],st.marks[0]); printf("physics= \t\t%.2f\t\t%.2f\n",st.total_marks[1],st.marks[1]); printf("Mechanics= \t\t%.2f\t\t%.2f\n",st.total_marks[2],st.marks[2]); printf("Mathematics=\t\t%.2f\t\t%.2f\n",st.total_marks[3],st.marks[3]); printf("Electrical= \t\t%.2f\t\t%.2f\n",st.total_marks[4],st.marks[4]); printf("Drawing= \t\t%.2f\t\t%.2f\n",st.total_marks[5],st.marks[5]); printf("\n\ntotal obtained marks=%f",st.obt_marks); printf("\nAverage marks=%f",st.avg_marks); printf("\nPercentage=%f",st.percent); printf("\n\t------------------------------\n\n\n\n"); } } CIVIL=fopen("D:\\civil.txt","rb"); if(CIVIL==NULL) { printf("\n\n\t\terror in opening civil.txt file"); getch(); break; } while(fread(&st,sizeof(st),1,CIVIL)==1) { if(st.percent<=fail) { printf("\nName=%s %s",st.f_name,st.l_name); printf("\nRoll number=%s",st.roll); printf("\nSection=%c",st.section); printf("\nBlood group=%s",st.bloodgroup); printf("\nPhone no=%s",st.phone_no); printf("\nAddress=%s",st.address); printf("\n\n \t\tMarks obtained in each subject are:>\n"); printf("Subject \t\ttotal marks\tobt marks\t\n\n"); printf("Computer= \t\t%.2f\t\t%.2f\n",st.total_marks[0],st.marks[0]); printf("physics= \t\t%.2f\t\t%.2f\n",st.total_marks[1],st.marks[1]); printf("Mechanics= \t\t%.2f\t\t%.2f\n",st.total_marks[2],st.marks[2]); printf("Mathematics=\t\t%.2f\t\t%.2f\n",st.total_marks[3],st.marks[3]); printf("Electrical= \t\t%.2f\t\t%.2f\n",st.total_marks[4],st.marks[4]); printf("Drawing= \t\t%.2f\t\t%.2f\n",st.total_marks[5],st.marks[5]); printf("\n\ntotal obtained marks=%f",st.obt_marks); printf("\nAverage marks=%f",st.avg_marks); printf("\nPercentage=%f",st.percent); printf("\n\t------------------------------\n\n\n\n"); } } getch(); fclose(BEX); fclose(BCT); fclose(CIVIL); break; case 7: system("cls"); printf("enter the blood group="); fflush(stdin); gets(blood); BEX=fopen("D:\\electronics.txt","rb"); if(BEX==NULL) { printf("\n\t\terror in opening electronics.txt file\n"); } while(fread(&st,sizeof(st),1,BEX)==1) { if(strcmp(st.bloodgroup,blood)==0) output(); } BCT=fopen("D:\\computer.txt","rb"); if(BCT==NULL) { printf("\n\n\t\terror in opening computer.txt file\n"); } while(fread(&st,sizeof(st),1,BCT)==1) { if(strcmp(st.bloodgroup,blood)==0) output(); } CIVIL=fopen("D:\\civil.txt","rb"); if(CIVIL==NULL) { printf("\n\n\t\terror in opening civil.txt file"); getch(); break; } while(fread(&st,sizeof(st),1,CIVIL)==1) { if(strcmp(st.bloodgroup,blood)==0) output(); } getch(); fclose(BEX); fclose(BCT); fclose(CIVIL); break; case 8: fclose(BEX); fclose(BCT); fclose(CIVIL); system("cls"); break; default : printf("enter the valid choice"); goto upper; break; } } void output() { printf("\nName=%s %s",st.f_name,st.l_name); printf("\nRoll number=%s",st.roll); printf("\nSection=%c",st.section); printf("\nBlood group=%s",st.bloodgroup); printf("\nPhone no=%s",st.phone_no); printf("\nAddress=%s",st.address); printf("\n\n \t\tMarks obtained in each subject are:>\n"); printf("Subject \t\ttotal marks\tobt marks\t\n\n"); printf("Computer= \t\t%.2f\t\t%.2f\n",st.total_marks[0],st.marks[0]); printf("physics= \t\t%.2f\t\t%.2f\n",st.total_marks[1],st.marks[1]); printf("Mechanics= \t\t%.2f\t\t%.2f\n",st.total_marks[2],st.marks[2]); printf("Mathematics=\t\t%.2f\t\t%.2f\n",st.total_marks[3],st.marks[3]); printf("Electrical= \t\t%.2f\t\t%.2f\n",st.total_marks[4],st.marks[4]); printf("Drawing= \t\t%.2f\t\t%.2f\n",st.total_marks[5],st.marks[5]); printf("\n\ntotal obtained marks=%.2f",st.obt_marks); printf("\nAverage marks=%.2f",st.avg_marks); printf("\nPercentage=%.2f",st.percent); printf("\n\t------------------------------\n\n\n\n"); } void division1() { if(st.percent>=dist) { printf("\nName=%s %s",st.f_name,st.l_name); printf("\nRoll number=%s",st.roll); printf("\nSection=%c",st.section); printf("\nBlood group=%s",st.bloodgroup); printf("\nPhone no=%s",st.phone_no); printf("\nAddress=%s",st.address); printf("\n\n \t\tMarks obtained in each subject are:>\n"); printf("Subject \t\ttotal marks\tobt marks\t\n\n"); printf("Computer= \t\t%.2f\t\t%.2f\n",st.total_marks[0],st.marks[0]); printf("physics= \t\t%.2f\t\t%.2f\n",st.total_marks[1],st.marks[1]); printf("Mechanics= \t\t%.2f\t\t%.2f\n",st.total_marks[2],st.marks[2]); printf("Mathematics=\t\t%.2f\t\t%.2f\n",st.total_marks[3],st.marks[3]); printf("Electrical= \t\t%.2f\t\t%.2f\n",st.total_marks[4],st.marks[4]); printf("Drawing= \t\t%.2f\t\t%.2f\n",st.total_marks[5],st.marks[5]); printf("\n\ntotal obtained marks=%f",st.obt_marks); printf("\nAverage marks=%f",st.avg_marks); printf("\nPercentage=%f",st.percent); printf("\n\t------------------------------\n\n\n\n"); } } void division2() { if(st.percent>=frist && st.percent<dist) { printf("\nName=%s %s",st.f_name,st.l_name); printf("\nRoll number=%s",st.roll); printf("\nSection=%c",st.section); printf("\nBlood group=%s",st.bloodgroup); printf("\nPhone no=%s",st.phone_no); printf("\nAddress=%s",st.address); printf("\n\n \t\tMarks obtained in each subject are:>\n"); printf("Subject \t\ttotal marks\tobt marks\t\n\n"); printf("Computer= \t\t%.2f\t\t%.2f\n",st.total_marks[0],st.marks[0]); printf("physics= \t\t%.2f\t\t%.2f\n",st.total_marks[1],st.marks[1]); printf("Mechanics= \t\t%.2f\t\t%.2f\n",st.total_marks[2],st.marks[2]); printf("Mathematics=\t\t%.2f\t\t%.2f\n",st.total_marks[3],st.marks[3]); printf("Electrical= \t\t%.2f\t\t%.2f\n",st.total_marks[4],st.marks[4]); printf("Drawing= \t\t%.2f\t\t%.2f\n",st.total_marks[5],st.marks[5]); printf("\n\ntotal obtained marks=%f",st.obt_marks); printf("\nAverage marks=%f",st.avg_marks); printf("\nPercentage=%f",st.percent); printf("\n\t------------------------------\n\n\n\n"); } } void division3() { if(st.percent>=sec && st.percent<frist) { printf("\nName=%s %s",st.f_name,st.l_name); printf("\nRoll number=%s",st.roll); printf("\nSection=%c",st.section); printf("\nBlood group=%s",st.bloodgroup); printf("\nPhone no=%s",st.phone_no); printf("\nAddress=%s",st.address); printf("\n\n \t\tMarks obtained in each subject are:>\n"); printf("Subject \t\ttotal marks\tobt marks\t\n\n"); printf("Computer= \t\t%.2f\t\t%.2f\n",st.total_marks[0],st.marks[0]); printf("physics= \t\t%.2f\t\t%.2f\n",st.total_marks[1],st.marks[1]); printf("Mechanics= \t\t%.2f\t\t%.2f\n",st.total_marks[2],st.marks[2]); printf("Mathematics=\t\t%.2f\t\t%.2f\n",st.total_marks[3],st.marks[3]); printf("Electrical= \t\t%.2f\t\t%.2f\n",st.total_marks[4],st.marks[4]); printf("Drawing= \t\t%.2f\t\t%.2f\n",st.total_marks[5],st.marks[5]); printf("\n\ntotal obtained marks=%f",st.obt_marks); printf("\nAverage marks=%f",st.avg_marks); printf("\nPercentage=%f",st.percent); printf("\n\t------------------------------\n\n\n\n"); } } void division4() { if(st.percent>=pass && st.percent<sec) { printf("\nName=%s %s",st.f_name,st.l_name); printf("\nRoll number=%s",st.roll); printf("\nSection=%c",st.section); printf("\nBlood group=%s",st.bloodgroup); printf("\nPhone no=%s",st.phone_no); printf("\nAddress=%s",st.address); printf("\n\n \t\tMarks obtained in each subject are:>\n"); printf("Subject \t\ttotal marks\tobt marks\t\n\n"); printf("Computer= \t\t%.2f\t\t%.2f\n",st.total_marks[0],st.marks[0]); printf("physics= \t\t%.2f\t\t%.2f\n",st.total_marks[1],st.marks[1]); printf("Mechanics= \t\t%.2f\t\t%.2f\n",st.total_marks[2],st.marks[2]); printf("Mathematics=\t\t%.2f\t\t%.2f\n",st.total_marks[3],st.marks[3]); printf("Electrical= \t\t%.2f\t\t%.2f\n",st.total_marks[4],st.marks[4]); printf("Drawing= \t\t%.2f\t\t%.2f\n",st.total_marks[5],st.marks[5]); printf("\n\ntotal obtained marks=%f",st.obt_marks); printf("\nAverage marks=%f",st.avg_marks); printf("\nPercentage=%f",st.percent); printf("\n\t------------------------------\n\n\n\n"); } } void search_modify() { int ch; char g,r[15],ph[15],fname[25],lname[25]; system("cls"); printf("\n\t\t1.search by name"); printf("\n\t\t2.search by roll number"); printf("\n\t\t3.search by phone number"); printf("\n\t\t4.return to menu"); printf("\n\n\t\t\tenter the choice(1,2,3,4)=>"); read: scanf("%d",&ch); switch(ch) { case 1: system("cls"); printf("\n\t\t\tenter the frist name:"); fflush(stdin); gets(fname); printf("\n\t\t\tenter the last name:"); fflush(stdin); gets(lname); BEX=fopen("D:\\electronics.txt","rb+"); if(BEX==NULL) { printf("\n\t\terror in opening electronics.txt file\n"); } while(fread(&st,sizeof(st),1,BEX)==1) { if(strcmp(st.f_name,fname)==0) { if(strcmp(st.l_name,lname)==0) { output(); printf("\n\n\t\tDo you want to modify this record"); printf("\n enter 'y' for yes or press any other key = "); scanf("%c",&g); if('y'==tolower(g)) { input(); fseek(BEX,-sizeof(st),SEEK_CUR); fwrite(&st,sizeof(st),1,BEX); break; } if('d'==tolower(g)) { if(strcmp(st.l_name,lname)==0) continue; rewind(BEX); } } } } fclose(BEX); BCT=fopen("D:\\computer.txt","rb+"); if(BCT==NULL) { printf("\n\t\terror in opening computer.txt file\n"); } while(fread(&st,sizeof(st),1,BCT)==1) { if(strcmp(st.f_name,fname)==0) { if(strcmp(st.l_name,lname)==0) { output(); printf("\n\n\t\tDo you want to modify this record"); printf("\n enter 'y' for yes or press any other key = "); scanf("%c",&g); if('y'==tolower(g)) { input(); fseek(BCT,-sizeof(st),SEEK_CUR); fwrite(&st,sizeof(st),1,BCT); break; } } } } fclose(BCT); CIVIL=fopen("D:\\civil.txt","rb+"); if(CIVIL==NULL) { printf("\n\t\terror in opening civil.txt file"); getch(); break; } while(fread(&st,sizeof(st),1,CIVIL)==1) { if(strcmp(st.f_name,fname)==0) { if(strcmp(st.l_name,lname)==0) { output(); printf("\n\n\t\tDo you want to modify this record"); printf("\n enter 'y' for yes or press any other key = "); scanf("%c",&g); if('y'==tolower(g)) { input(); fseek(CIVIL,-sizeof(st),SEEK_CUR); fwrite(&st,sizeof(st),1,CIVIL); break; } } } } getch(); fclose(CIVIL); break; case 2: system("cls"); printf("\n\t\t\tenter the roll number you want to search:"); fflush(stdin); gets(r); BEX=fopen("D:\\electronics.txt","rb+"); if(BEX==NULL) { printf("\n\t\terror in opening electronics.txt file\n"); } while(fread(&st,sizeof(st),1,BEX)==1) { if(strcmp(st.roll,r)==0) { output(); printf("\n\n\t\tDo you want to modify this record"); printf("\n enter 'y' for yes or press any other key = "); scanf("%c",&g); if('y'==tolower(g)) { input(); fseek(BEX,-sizeof(st),SEEK_CUR); fwrite(&st,sizeof(st),1,BEX); break; } } } fclose(BEX); BCT=fopen("D:\\computer.txt","rb+"); if(BCT==NULL) { printf("\n\t\terror in opening computer.txt file\n"); } while(fread(&st,sizeof(st),1,BCT)==1) { if(strcmp(st.roll,r)==0) { output(); printf("\n\n\t\tDo you want to modify this record"); printf("\n enter 'y' for yes or press any other key = "); scanf("%c",&g); if('y'==tolower(g)) { input(); fseek(BCT,-sizeof(st),SEEK_CUR); fwrite(&st,sizeof(st),1,BCT); break; } } } fclose(BCT); CIVIL=fopen("D:\\civil.txt","rb+"); if(CIVIL==NULL) { printf("\n\t\terror in opening civil.txt file"); getch(); break; } while(fread(&st,sizeof(st),1,CIVIL)==1) { if(strcmp(st.roll,r)==0) { output(); printf("\n\n\t\tDo you want to modify this record"); printf("\n enter 'y' for yes or press any other key = "); scanf("%c",&g); if('y'==tolower(g)) { input(); fseek(CIVIL,-sizeof(st),SEEK_CUR); fwrite(&st,sizeof(st),1,CIVIL); break; } } } getch(); fclose(CIVIL); break; case 3: system("cls"); printf("\n\tenter the phone number you want to search:"); fflush(stdin); gets(ph); BEX=fopen("D:\\electronics.txt","rb+"); if(BEX==NULL) { printf("\n\t\terror in opening electronics.txt file\n"); } while(fread(&st,sizeof(st),1,BEX)==1) { if(strcmp(st.phone_no,ph)==0) { output(); printf("\n\n\tDo you want to modify this record"); printf("\n enter 'y' for yes or press any other key = "); scanf("%c",&g); if('y'==tolower(g)) { input(); fseek(BEX,-sizeof(st),SEEK_CUR); fwrite(&st,sizeof(st),1,BEX); break; } } } fclose(BEX); BCT=fopen("D:\\computer.txt","rb+"); if(BCT==NULL) { printf("\n\t\terror in opening computer.txt file\n"); } while(fread(&st,sizeof(st),1,BCT)==1) { if(strcmp(st.phone_no,ph)==0) { output(); printf("\n\n\t\tDo you want to modify this record"); printf("\n enter 'y' for yes or press any other key = "); scanf("%c",&g); if('y'==tolower(g)) { input(); fseek(BCT,-sizeof(st),SEEK_CUR); fwrite(&st,sizeof(st),1,BCT); break; } } } fclose(BCT); CIVIL=fopen("D:\\civil.txt","rb+"); if(CIVIL==NULL) { printf("\n\t\terror in opening civil.txt file"); getch(); break; } while(fread(&st,sizeof(st),1,CIVIL)==1) { if(strcmp(st.phone_no,ph)==0) { output(); printf("\n\n\t\tDo you want to modify this record"); printf("\n enter 'y' for yes or press any other key = "); scanf("%c",&g); if('y'==tolower(g)) { input(); fseek(CIVIL,-sizeof(st),SEEK_CUR); fwrite(&st,sizeof(st),1,CIVIL); break; } } } getch(); fclose(CIVIL); break; case 4: break; default : printf("invalid choice\?\?--please enter correct choice"); goto read; break; } } void delete() { } |
Output Sample:
Click Here to Download Complete Code and output.