Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include<conio.h>
- #include<process.h>
- #include <stdlib.h>
- #include <string.h>
- //sub main 3 function
- void admin();
- void teacher();
- void student();
- //-----------------------------Student-----------------Part------------------
- //Student information
- void input_student_details(); //check
- void input_student_result();
- //Student search
- void student_search();
- // void student_search_by_name();
- // void student_search_by_roll(); //check
- //Display part
- void display_student_information();
- void display_student_information_result(); //check
- //------------------------------Teacher------------------------------Part-----------------------
- //teacher information
- void input_teacher_details(); //check
- //search
- void teacher_search();
- //void teacher_search_by_name();
- //void teacher_search_by_subject_name();
- //display teacher information
- void display_teacher_details();
- //-----------------------------Admin----------------------------------Part--------------
- void check(); //Checking mark
- //void show_avareage_mark();
- void check_bangla_pass_fail();
- void check_english_pass_fail();
- void check_math_pass_fail();
- void check_social_science_pass_fail();
- void check_general_science_pass_fail();
- struct student
- {
- char name[30];
- int password[10];
- char cls[10];
- int Roll;
- char age[3];
- char subject_name[20];
- char counselling_time[20];
- //char counseling_date[10];
- int bangla_marks,english_marks,math_marks,socialScience_marks,generalScience_marks;
- char phone_no[11];
- float per;
- char grade;
- int std;
- } information;
- //long si=sizeof(s);
- int main()
- {
- system("cls");
- system("color B");
- int choice;
- printf("\t\t\t\t\t*****GOPALPUR HIGH SCHOOL*****");
- printf("\n\t\t\t\t\t**School Management System**");
- printf("\n\t\t\t\t******************************************");
- printf("\n\n\n\t\t\t\t\t1.Administrator Login");
- printf("\n\t\t\t\t\t2.Teacher Login");
- printf("\n\t\t\t\t\t3.Student Login");
- printf("\n\n\t\t\t\t\tPlease enter your choice: ");
- scanf("%d",&choice);
- switch(choice)
- {
- case 0:
- exit(0);
- case 1:
- admin();
- break;
- case 2:
- teacher();
- break;
- case 3:
- student();
- break;
- default:
- printf("Errors");
- break;
- }
- return 0;
- }
- // user define function start....
- //-----------------------------------Teacher------------Part-------------------------------------
- FILE *fp01;
- void input_teacher_details()
- {
- system("cls");
- fp01=fopen("teacher.txt","ab");
- printf("Enter the teacher name: ");
- fflush(stdin);
- gets(information.name);
- printf("Enter the age: ");
- fflush(stdin);
- gets(information.age);
- printf("Enter the subject name: ");
- fflush(stdin);
- gets(information.subject_name);
- printf("Enter the counseling time : ");
- fflush(stdin);
- gets(information.counselling_time);
- printf("Enter the phone number: ");
- fflush(stdin);
- gets(information.phone_no);
- fwrite(&information, sizeof(information),1,fp01);
- printf("Record save successfully\n");
- fclose(fp01);
- }
- //FILE *file3;
- void teacher()
- {
- system("cls");
- char name[20],password[8];
- int i,choice;
- //file3=fopen("teacher.txt","a");
- //if(file3==NULL)
- //{
- // printf("File doesn't exists.");
- // return 0;
- // }else{
- printf("\n\t\t\t\t\t***Teacher***");
- printf("\n\t\t\t\tEnter your name: ");
- scanf("%s",&name);
- printf("\n\t\t\t\tEnter our password: ");
- for(i=0; i<6; i++)
- {
- password[i]=getch();
- printf("*");
- }
- password[i]='\0';
- if(strcmp(name,"hasan")==0 && strcmp(password,"mehedi")==0)
- {
- printf("\n\n\t\t\t\t\t1.Input Teacher details");
- printf("\n\t\t\t\t\t2.Display Teacher Information");
- printf("\n\t\t\t\t\t3.Display Student Information");
- printf("\n\t\t\t\t\t4.Display Student Information & Result");
- printf("\n\t\t\t\t\t5.Search A Teacher");
- printf("\n\t\t\t\t\t6.Search A Student");
- printf("\n\t\t\t\t\t7.Check");
- printf("\n\t\t\t\t\t8.Back To Main Menu");
- printf("\n\t\t\t\tEnter your choice: ");
- scanf("%d",&choice);
- switch(choice)
- {
- case 0:
- exit(0);
- case 1:
- input_teacher_details();
- break;
- case 2:
- display_teacher_details();
- break;
- case 3:
- display_student_information();
- break;
- case 4:
- display_student_information_result();
- break;
- case 5:
- teacher_search();
- break;
- case 6:
- student_search();
- break;
- case 7:
- check();
- break;
- case 8:
- system("cls");
- main();
- break;
- default: printf("Error");
- }
- }
- else
- printf("Check your name or password...");
- // }
- // fclose(file3);
- }
- void display_teacher_details()
- {
- system("cls");
- printf("<== Teacher Information ==>\n\n");
- printf("%-30s %-20s %-20s %-20s\t %s\n","Name","Age","Subject","Counseling_Time","Phone_No");
- fp01 = fopen("teacher.txt","rb");
- while(fread(&information ,sizeof(information) ,1,fp01)==1)
- {
- printf("%-30s %-20s %-20s %-20s\t %s\n",information.name ,information.age ,information.subject_name, information.counselling_time ,information.phone_no);
- }
- fclose(fp01);
- printf("Press any key to continue...");
- }
- void teacher_search()
- {
- system("cls");
- char na[30];
- int f=0;
- printf("Enter Name to search: ");
- fflush(stdin);
- gets(na);
- printf("%-30s %-20s %-20s %-20s\t %s\n","Name","Age","Subject","Counseling_Time","Phone_No");
- fp01=fopen("teacher.txt","rb");
- while(fread(&information,sizeof(information),1,fp01)==1)
- {
- if(strcmp(na,information.name)==0)
- {
- f=1;
- printf("%-30s %-20s %-20s %-20s\t %s\n",information.name ,information.age ,information.subject_name ,information.counselling_time ,information.phone_no);
- printf("Record Found Successfully...\n");
- printf("Press any key to continue...\n\n");
- break;
- }
- }
- fclose(fp01);
- if(f==0)
- printf("Record Not Found...\n");
- }
- //-------------------------------Student------------part--------------------------------------------
- FILE *file2;
- void student()
- {
- system("cls");
- char name[20],password[8],ch='*';
- int i, choice;
- file2=fopen("student.txt","rb");
- if(file2==NULL)
- {
- printf("File doesn't exists");
- return;
- }
- printf("\n\t\t\t\t\t***Student***\n");
- printf("\n\t\t\t\tEnter your name: ");
- scanf("%s",&name);
- printf("\n\t\t\t\tEnter your password: ");
- for(i=0; i<5; i++)
- {
- password[i]=getch();
- printf("*");
- }
- password[i]='\0';
- if(strcmp(name,"zahid")==0 && strcmp(password,"mahdi")==0)
- {
- printf("\n\n\t\t\t\t\t***Student Login Successfully***\n");
- while(1)
- {
- printf("\n\n\t\t\t\t\t1. Display Teacher Information ");
- printf("\n\t\t\t\t\t2. Search A Teacher");
- printf("\n\t\t\t\t\t3. View Your Information");
- printf("\n\t\t\t\t\t4. View Your Information & Result");
- printf("\n\t\t\t\t\t5. Back To Main Menu");
- printf("\n\t\t\t\tEnter your choice: ");
- scanf("%d",&choice);
- switch(choice)
- {
- case 0:
- exit(0);
- case 1:
- display_teacher_details();
- break;
- case 2:
- teacher_search();
- break;
- case 3:
- display_student_information();
- break;
- case 4:
- display_student_information_result();
- break;
- case 5:
- system("cls");
- main();
- break;
- default:
- printf("Error");
- break;
- }
- }
- }
- else
- printf("\n Check Your Name Or Password...\n");
- fclose(file2);
- }
- FILE *fp02;
- void input_student_details()
- {
- system("cls");
- fp02=fopen("student.txt","ab+");
- printf("Enter the student name: ");
- fflush(stdin);
- gets(information.name);
- printf("Enter the class: ");
- gets(information.cls);
- printf("Enter the roll: ");
- scanf("%d",&information.Roll);
- printf("Enter the age: ");
- scanf("%d",&information.age);
- fflush(stdin);
- printf("Enter the guardian phone no.: ");
- gets(information.phone_no);
- fwrite(&information, sizeof(information),1,fp02);
- printf("Record successfully\n");
- fclose(fp02);
- }
- FILE *fp03;
- void input_student_result()
- {
- system("cls");
- fp03=fopen("result.txt","ab+");
- printf("Enter Student Name: ");
- fflush(stdin);
- gets(information.name);
- printf("Enter Class: ");
- scanf("%s",&information.cls);
- printf("Enter roll: ");
- scanf("%d",&information.Roll);
- printf("\nEnter The marks in Bangla out of 100 : ");
- scanf("%d",&information.bangla_marks);
- printf("\nEnter The marks in English out of 100 : ");
- scanf("%d",&information.english_marks);
- printf("\nEnter The marks in Mathematics out of 100 : ");
- scanf("%d",&information.math_marks);
- printf("\nEnter The marks in Social Science out of 100 : ");
- scanf("%d",&information.socialScience_marks);
- printf("\nEnter The marks in General Science out of 100 : ");
- scanf("%d",&information.generalScience_marks);
- information.per=(information.bangla_marks +information.english_marks +information.math_marks +information.socialScience_marks +information.generalScience_marks)/5.0;
- fwrite(&information, sizeof(information),1,fp03);
- printf("Record Saved Successfully");
- fclose(fp03);
- }
- void display_student_information()
- {
- system("cls");
- printf("<== Student Information ==>\n\n");
- printf("%s\t\t %s\t\t %s\t\t %s\n","Name","Class","Roll","Guardian_Number");
- fp02= fopen("student.txt","rb");
- while(fread(&information,sizeof(information),1,fp02)==1)
- {
- printf("%s\t\t %s\t\t %d\t\t %d\t\t %s\n",information.name ,information.cls ,information.Roll,information.phone_no);
- }
- fclose(fp02);
- printf("Press any key to continue...");
- }
- void display_student_information_result()
- {
- system("cls");
- printf("\n\n\n\t\tDISPLAY ALL RECORD !!!\n\n");
- fp03=fopen("result.txt","rb+");
- while((fread(&information,sizeof(information),1,fp03))>0)
- {
- printf("\nName of student : %s",information.name);
- printf("\nName of class : %s",information.cls);
- printf("\nNumber of roll : %d",information.Roll);
- printf("\n\nMarks in Bangla : %d",information.bangla_marks);
- printf("\nMarks in English : %d",information.english_marks);
- printf("\nMarks in Mathematics : %d",information.math_marks);
- printf("\nMarks in Social Science : %d",information.socialScience_marks);
- printf("\nMarks in General Science : %d",information.generalScience_marks);
- printf("\nPercentage of student is : %.2f",information.per);
- printf("\n\n====================================\n");
- printf("Press any key to continue...");
- getch();
- }
- fclose(fp03);
- }
- void student_search()
- {
- system("cls");
- char na[30];
- int f=0;
- printf("Enter Name to search: ");
- fflush(stdin);
- gets(na);
- printf("%s\t\t %s\t\t %s\t\t %s\t\t %s\n","Name","Class","Roll","Age","Guardian_Number");
- fp02=fopen("student.txt","rb");
- while(fread(&information,sizeof(information),1,fp02)==1)
- {
- if(strcmpi(na,information.name)==0)
- {
- f=1;
- printf("%s\t\t %s\t\t %d\t\t %d\t\t %s\n",information.name ,information.cls ,information.Roll ,information.age ,information.phone_no);
- printf("Record Found Successfully...\n");
- printf("Press any key to continue...\n\n");
- break;
- }
- }
- fclose(fp02);
- if(f==0)
- printf("Record Not Found...\n");
- }
- //-----------------------------------Admin-----Part----------------------------------------------------------------
- FILE *file1;
- void admin()
- {
- system("color A");
- system("cls");
- int choice,i;
- char name[20],password[8];
- file1=fopen("Administrators.txt","wb");
- if(file1==NULL)
- {
- printf("There is no exist file\n");
- return 0;
- }
- printf("\t\t\t\t\tFor Administrator\n");
- printf("\n\t\t\t\tEnter your name: ");
- scanf("%s",name);
- printf("\n\t\t\t\tEnter the password: ");
- for(i=0; i<5;i++)
- {
- password[i]=getch();
- printf("*");
- }
- password[i]='\0';
- fwrite(&information, sizeof(information),1,file1);
- if(strcmp(name,"zahid")==0 && strcmp(password,"hasan")==0 )
- {
- printf("\n\n\t\t\t\tAdmin Login Successfully");
- while(1)
- {
- printf("\n\n\t\t\t\t\t1. Display teachers detail");
- printf("\n\t\t\t\t\t2. Search a teacher");
- printf("\n\t\t\t\t\t3. Student information input & editing");
- printf("\n\t\t\t\t\t4. Student information and result input and editing");
- printf("\n\t\t\t\t\t5. Display student information");
- printf("\n\t\t\t\t\t6. Display student information and result");
- printf("\n\t\t\t\t\t7. Search a student");
- printf("\n\t\t\t\t\t8. Check");
- printf("\n\t\t\t\t\t9. Back To Main Menu");
- fwrite(&information, sizeof(information),1,file1);
- printf("\n\n Please enter your choice:");
- scanf("%d",&choice);
- switch(choice)
- {
- case 0:
- exit (0);
- case 1:
- display_teacher_details();
- break;
- case 2:
- teacher_search();
- break;
- case 3:
- input_student_details();
- break;
- case 4:
- input_student_result();
- break;
- case 5:
- display_student_information();
- break;
- case 6:
- display_student_information_result();
- break;
- case 7:
- student_search();
- break;
- case 8:
- check();
- break;
- case 9:
- system("cls");
- main();
- break;
- default:
- printf("errors");
- }
- }
- }
- else
- {
- printf("\t\tCheck your name or password...\n");
- }
- fclose(file1);
- }
- void check()
- {
- system("cls");
- int ch;
- while(1)
- {
- printf("<== Varsity Management ==>\n");
- printf("<== Check ==>\n\n");
- printf("1.Check Bangla pass fail\n");
- printf("2.Check English pass fail \n");
- printf("3.Check Mathematics pass fail\n");
- printf("4.Check Social Science pass fail\n");
- printf("5.Check General Science pass fail\n");
- printf("6.Back To Admin menu\n");
- printf("\n\nEnter your choice: ");
- scanf("%d",&ch);
- switch(ch)
- {
- case 1:
- check_bangla_pass_fail();
- break;
- case 2:
- check_english_pass_fail();
- break;
- case 3:
- check_math_pass_fail();
- break;
- case 4:
- check_social_science_pass_fail();
- break;
- case 5:
- check_general_science_pass_fail();
- break;
- case 6:
- system("cls");
- admin();
- break;
- default:
- printf("Invalid Choice");
- }
- getch();
- }
- }
- void check_bangla_pass_fail()
- {
- system("cls");
- float result[10],greatest;
- int i =0;
- int f=0;
- int n;
- int count1=0,count2=0;
- printf("Total student: \n");
- scanf("%d",&n);
- printf("The Bangla results are:\n");
- for (i = 1; i < n+1; i++)
- {
- printf("The %dst student result is:\n",i);
- scanf("%f", &result[i]);
- }
- for (i = 1; i < n+1; i++)
- {
- if(result[i]>33)
- count1++;
- else
- count2++;
- }
- printf("Total pass in Bangla is: %d\n",count1);
- printf("Total fail in Bangla is: %d\n\n",count2);
- printf("Press any key to continue...\n\n");
- }
- void check_english_pass_fail()
- {
- system("cls");
- float result[10],greatest;
- int i =0;
- int f=0;
- int n;
- int count1=0,count2=0;
- printf("Total student: \n");
- scanf("%d",&n);
- printf("The English results are:\n");
- for (i = 1; i < n+1; i++)
- {
- printf("The %dst student result is:\n",i);
- scanf("%f", &result[i]);
- }
- for (i = 1; i < n+1; i++)
- {
- if(result[i]>33)
- count1++;
- else
- count2++;
- }
- printf("Total pass in Math is: %d\n",count1);
- printf("Total fail in Math is: %d\n\n",count2);
- printf("Press any key to continue...\n\n");
- }
- void check_math_pass_fail()
- {
- system("cls");
- float result[10],greatest;
- int i =0;
- int f=0;
- int n;
- int count1=0,count2=0;
- printf("Total student: \n");
- scanf("%d",&n);
- printf("The Mathematics results are:\n");
- for (i = 1; i < n+1; i++)
- {
- printf("The %dst student result is:\n",i);
- scanf("%f", &result[i]);
- }
- for (i = 1; i < n+1; i++)
- {
- if(result[i]>33)
- count1++;
- else
- count2++;
- }
- printf("Total pass in Mathematics is: %d\n",count1);
- printf("Total fail in Mathematics is: %d\n\n",count2);
- printf("Press any key to continue...\n\n");
- }
- void check_social_science_pass_fail()
- {
- system("cls");
- float result[10],greatest;
- int i =0;
- int f=0;
- int n;
- int count1=0,count2=0;
- printf("Total student: \n");
- scanf("%d",&n);
- printf("The Social Science results are:\n");
- for (i = 1; i < n+1; i++)
- {
- printf("The %dst student result is:\n",i);
- scanf("%f", &result[i]);
- }
- for (i = 1; i < n+1; i++)
- {
- if(result[i]>33)
- count1++;
- else
- count2++;
- }
- printf("Total pass in Social Science is: %d\n",count1);
- printf("Total fail in Social Science is: %d\n\n",count2);
- printf("Press any key to continue...\n\n");
- }
- void check_general_science_pass_fail()
- {
- system("cls");
- float result[10],greatest;
- int i =0;
- int f=0;
- int n;
- int count1=0,count2=0;
- printf("Total student: \n");
- scanf("%d",&n);
- printf("The General Science results are:\n");
- for (i = 1; i < n+1; i++)
- {
- printf("The %dst student result is:\n",i);
- scanf("%f", &result[i]);
- }
- for (i = 1; i < n+1; i++)
- {
- if(result[i]>33)
- count1++;
- else
- count2++;
- }
- printf("Total pass in General science is: %d\n",count1);
- printf("Total fail in General Science is: %d\n\n",count2);
- printf("Press any key to continue...\n\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement