SlideShare a Scribd company logo
#include<iostream> 
#include<conio.h> 
#include<process.h> 
#include<windows.h> 
#include<string.h> 
#include<stdio.h> 
#include<fstream> 
using namespace std; 
void student_input(char); 
void student_output(char); 
void st_delete(char); 
void modify(char); 
void tfileinput(); 
void ttmodify() ; 
void tfileoutput(); 
void tdelet(); 
class student 
{ 
int rollno , year ; 
// student data to be entered 
long long contactno; 
char name[40] , father_name[50] , gender ,course[50] ,dob[20] , 
hometown[50] ; 
public: 
student(); 
void input(); 
void output(); 
void smodify(); 
int getrollno(); 
void menu(); 
void displaylist(); 
}; 
class teacher 
{ 
int teacher_id , age; 
float salary; 
//teacher data to be entered 
char name[40] , gender , subject[70]; 
public: 
teacher(); 
void input(); 
void output(); 
void tmodify(); 
int get_teacher_id(); 
void menu(); 
void displaylist(); 
}; 
/****************************************STUDENT 
CONSTRUCTOR***************************************/ 
student::student() 
{ 
rollno=year=contactno=0; 
strcpy(name,"NULL"); 
strcpy(father_name,"NULL"); 
strcpy(course,"NULL"); 
strcpy(course,"NULL"); 
strcpy(dob,"NULL"); 
strcpy(hometown,"NULL"); 
gender='0'; 
} 
/********************************************TEACHER 
CONSTRUCTOR*******************************************************/ 
teacher::teacher()
{ 
teacher_id=age=salary=0; 
strcpy(name,"NULL"); 
gender='0'; 
strcpy(subject,"NULL"); 
} 
void display() 
{ 
for(int i=0;i<3;i++) 
{ 
cout<<"nnnttSTUDENT AND TEACHER DATABASEn"; 
cout<<"nnnntttLOADINGt"; 
for(int j=0;j<3;j++) 
{ 
cout<<" . "; 
Sleep(350); 
} 
system("cls"); 
} 
} 
/***********************************STUDENT 
MENU********************************************************************/ 
void student::menu() 
{ 
char c,ch,n; 
system("cls"); 
cout<<"ntEnter year whose records to be maintainednFor First year press 
1nFor Second year press 2nFor Third year press 3n"; 
cin>>n; 
do 
{ 
system("cls"); 
cout<<"ntttEnter choice:n"; 
cout<<"ntt1. Student Detailsn"; 
cout<<"ntt2. Add new recordn"; 
cout<<"ntt3. Modify a recordn"; 
cout<<"ntt4. Delete a recordn"; 
cout<<"ntt5. Return to main menun"; 
cout<<"ntt6. Exit from programn"; 
cin>>c; 
cout<<"n"; 
switch(c) 
{ 
case '1': student_output(n); 
break; 
case '2': student_input(n); 
break; 
case '3': modify(n); 
break; 
case '4': st_delete(n); 
break; 
case '5': return; 
case '6': system("cls"); 
cout<<"nHave a nice day :)n";
getch(); 
exit(0); 
} 
cout<<"ntDo you want to continuen"; 
cin>>ch; 
}while(ch=='y'||ch=='Y'); 
} 
/***********************************TEACHER 
MENU********************************************************************/ 
void teacher::menu() 
{ 
char c,ch; 
do 
{ 
system("cls"); 
cout<<"nttEnter choice:n"; 
cout<<"ntt1. Teacher Detailsn"; 
cout<<"ntt2. Add new recordn"; 
cout<<"ntt3. Modify a recordn"; 
cout<<"ntt4. Delete a recordn"; 
cout<<"ntt5. Return to main menun"; 
cout<<"ntt6. Exit from programn"; 
cin>>c;cout<<"n"; 
switch(c) 
{ 
case '1': tfileoutput(); 
break; 
case '2': tfileinput(); 
break; 
case '3': ttmodify(); 
break; 
case '4': tdelet(); 
break; 
case '5': return ; 
case '6': system("cls"); 
cout<<"nHave a nice day :)n"; 
getch(); 
exit(0); 
} 
cout<<"ntDo you want to continuen"; 
cin>>ch; 
}while(ch=='y'||ch=='Y'); 
} 
void student_input(char q) 
//writing student records in file 
{ 
student s; 
int n; 
ofstream fout; 
cout<<"nHow many records do u want to Entern"; 
cin>>n; 
switch(q) 
{ 
case '1':fout.open("stud1.txt",ios::app);
break; 
case '2':fout.open("stud2.txt",ios::app); 
break; 
case '3':fout.open("stud3.txt",ios::app); 
break; 
} 
while(n--) 
{ 
s.input(); 
fout.write((char*)(&s),sizeof(s)); 
} 
fout.close(); 
} 
void tfileinput() 
//writing teacher record in file 
{ 
teacher t; 
int n; 
ofstream fout; 
cout<<"nHow many records do u want to entern"; 
cin>>n; 
fout.open("teacher.txt",ios::app); 
while(n--) 
{ 
t.input(); 
fout.write((char*)(&t),sizeof(t)); 
} 
fout.close(); 
} 
void student::displaylist() 
//STUDENT DISPLAY LIST 
{ 
cout<<rollno<<"tt"<<name<<"n"; 
} 
void teacher::displaylist() 
//TEACHER DISPLAY LIST 
{ 
cout<<teacher_id<<"tt"<<name<<"n"; 
} 
void student_output(char q) 
{ 
system("cls"); 
ifstream fin; 
//output 
student 
student s; 
int f=0; 
switch(q) 
{ 
case '1': fin.open("stud1.txt"); 
break; 
case '2': fin.open("stud2.txt");
break; 
case '3': fin.open("stud3.txt"); 
break; 
} 
cout<<"ntttSTUDENT LISTn"<<"nRoll No. "<<"t Namen"; 
while(fin.read((char*)(&s),sizeof(s))) 
//To print student details list 
s.displaylist(); 
int n; 
fin.close(); 
switch(q) 
{ 
case '1':fin.open("stud1.txt"); 
break; 
case '2':fin.open("stud2.txt"); 
break; 
case '3':fin.open("stud3.txt"); 
break; 
} 
cout<<"nnttEnter Roll no. whose record you want to See ('-1' to go back 
to previous menu)n"; 
cin>>n; 
if(n==-1) 
{ 
system("cls"); 
return; 
} 
system("cls"); 
while(fin.read((char*)(&s),sizeof(s))) 
//To print student file details 
{ 
if(n==s.getrollno()) 
{ 
s.output(); 
f=1; 
} 
} 
if(f==0) 
cout<<"nStudent record not found !!!n"; 
fin.close(); 
} 
/***************************TEACHER READ FROM FILE 
FUNCTION******************************************************************/ 
void tfileoutput() 
{ 
system("cls"); 
ifstream fin; 
teacher t; 
int f=0; 
fin.open("teacher.txt"); 
cout<<"ttTEACHER LISTnn"; 
cout<<"IDtt"<<"Namenn"; 
while(fin.read((char*)(&t),sizeof(t))) 
t.displaylist(); 
int n; 
fin.close(); 
cout<<"nnEnter Teacher ID whose record you want to see ('-1' to go back to
previous menu)n"; 
cin>>n; 
if(n==-1) 
{ 
system("cls"); 
return; 
} 
system("cls"); 
fin.open("teacher.txt"); 
while(fin.read((char*)(&t),sizeof(t))) 
{ 
if(n==t.get_teacher_id()) 
{ 
t.output(); 
f=1; 
} 
} 
if(f==0) 
cout<<"nEntered ID not Foundn"; 
fin.close(); 
} 
/************************************STUDENT MODIFY 
FUNCTION************************************************/ 
void modify(char q) 
{ 
fstream fio; 
switch(q) 
{ 
case '1':fio.open("stud1.txt"); 
break; 
case '2':fio.open("stud2.txt"); 
break; 
case '3':fio.open("stud3.txt"); 
break; 
} 
int no; 
long pos; 
student s; 
char found='f'; 
cout<<"nntEnter the roll no. whose record is to be modified n "; 
cin>>no; 
fio.seekg(0); 
while(!fio.eof()) 
{ 
pos=fio.tellg(); 
fio.read((char *)&s, sizeof(s)); 
if(s.getrollno()==no) 
{ 
fio.seekg(pos); 
system("cls"); 
s.output(); 
s.smodify(); 
fio.write((char*) &s, sizeof(s)); 
found='t'; 
break ; 
} 
} 
if(found=='f') 
cout<<"nntRecord not found !!n"; 
fio.close(); 
getch();
} 
void student::smodify() 
{ 
int srollno , syear ; // 
temporary data storages 
long long scontactno; 
char sname[40] , sfather_name[50] , sgender , scourse[50] , sdob[20] , 
shometown[50] ; 
cout<<"nEnter New Detailsn"; 
cout<<"nRoll No. (-1 to retain old one)n"; 
cin>>srollno; 
cout<<"nName ('.' to retain old one )n"; 
cin.ignore(40,'n'); 
cin.getline(sname,40,'n'); 
cout<<"nFather'sName ('.' to retain old one )n"; 
//cin.ignore(40,'n'); 
cin.getline(sfather_name,40,'n'); 
cout<<"nDate of birth ('.' to retain old one )n"; 
cin.getline(sdob,20,'n'); 
cout<<"nGender (M/F) ('.' to retain old one )n"; 
cin>>sgender; 
cout<<"nContact no. (-1 to retain old one)n"; 
cin>>scontactno; 
cout<<"nCourse ('.' to retain old one )n"; 
cin.ignore(50,'n'); 
cin.getline(scourse,50,'n'); 
cout<<"nHometown ('.' to retain old one )n"; 
//cin.ignore(50,'n'); 
cin.getline(shometown,50,'n'); 
cout<<"Year (-1 to retain old one)n"; 
cin>>syear; 
if(srollno != -1) 
rollno=srollno; 
if(scontactno != -1) 
contactno=scontactno; 
if(syear != -1) 
year=syear; 
if(strcmp(sname,".") != 0) 
strcpy(name,sname); 
if(sgender != '.') 
gender=sgender; 
if(strcmp(sfather_name,".") != 0) 
strcpy(father_name,sfather_name); 
if(strcmp(shometown,".") != 0) 
strcpy(hometown,shometown); 
if(strcmp(sdob,".") != 0)
strcpy(dob,sdob); 
if(strcmp(scourse,".") != 0) 
strcpy(course,scourse); 
} 
/*************************************************TEACHER MODIFY 
FUNCTION*******************************************************/ 
void ttmodify() 
{ 
system(" cls "); 
fstream fio; 
int no; 
long pos; 
teacher t; 
char found='f'; 
fio.open("teacher.txt",ios::in|ios::out); 
cout<<"nntEnter the ID whose record is to be modified n "; 
cin>>no; 
fio.seekg(0); 
while(!fio.eof()) 
{ 
pos=fio.tellg(); 
fio.read((char *)&t, sizeof(t)); 
if(t.get_teacher_id()==no) 
{ 
fio.seekg(pos); 
system("cls"); 
t.output(); 
t.tmodify(); 
fio.write((char*) &t, sizeof(t)); 
found='t'; 
break ; 
} 
} 
if(found=='f') 
cout<<"nntRecord not found !!n"; 
fio.close(); 
getch(); 
} 
void teacher::tmodify() 
{ 
int tteacher_id , tage; 
float tsalary; 
//temporary teacher data to be entered 
char tname[40] , tgender , tsubject[70]; 
cout<<"nnEnter New Detailsnn"; 
cout<<"Enter New Teacher ID ('-1' to retain old one )n"; 
cin>>tteacher_id; 
cout<<"nName ('.' to retain old one )n"; 
cin.ignore(40,'n'); 
cin.getline(tname,40,'n'); 
cout<<"nAge ('-1' to retain old one )n"; 
cin>>tage; 
cout<<"nEnter gender(M/F) ('.' to retain old one )n"; 
cin>>tgender; 
cout<<"nEnter Subject ('.' to retain old one )n";
cin.ignore(40,'n'); 
cin.getline(tsubject,70,'n'); 
cout<<"nEnter salary ('-1' to retain old one )n"; 
cin>>tsalary; 
if(tteacher_id != -1) 
teacher_id=tteacher_id; 
if(strcmp(tname,".") != 0) 
strcpy(name,tname); 
if(strcmp(tsubject,".") != 0) 
strcpy(subject,tsubject); 
if(tsalary != -1) 
salary=tsalary; 
if(tage != -1) 
age=tage; 
if(tgender != '.') 
gender=tgender; 
} 
/*************************************STUDENT RECORD DELETE FUNCTION 
FUNCTION*********************************************/ 
void st_delete(char q) 
{ 
int n; 
char ch,f; 
student s; 
ifstream fin; 
ofstream fout; 
fout.open("temp.txt"); 
switch(q) 
{ 
case '1':fin.open("stud1.txt"); 
break; 
case '2':fin.open("stud2.txt"); 
break; 
case '3':fin.open("stud3.txt"); 
break; 
} 
cout<<"nEnter roll no. whose record you want to DELETEn"; 
cin>>n; 
system("cls"); 
while(fin.read((char*)(&s),sizeof(s))) 
{ 
if(n==s.getrollno()) 
{ 
f='y'; 
s.output(); 
cout<<"nCONFIRM DELETE(Y/N)n"; 
cin>>ch; 
if(ch=='y'||ch=='Y') 
{ 
cout<<"nRECORD DELETEDn"; 
getch(); 
continue; 
}
} 
fout.write((char*)&s,sizeof(s)); 
} 
if(f!='y') 
cout<<"nstudent record not foundn"; 
fin.close(); 
fout.close(); 
switch(q) 
{ 
case '1':remove("stud1.txt"); 
rename("temp.txt","stud1.txt"); 
break; 
case '2':remove("stud2.txt"); 
rename("temp.txt","stud2.txt"); 
break; 
case '3':remove("stud3.txt"); 
rename("temp.txt","stud3.txt");; 
break; 
} 
} 
/*************************************TEACHER RECORD DELETE FUNCTION 
FUNCTION*********************************************/ 
void tdelet() 
{ int n; 
char ch,f; 
teacher t; 
ifstream fin; 
ofstream fout; 
fin.open("teacher.txt"); 
fout.open("temp.txt"); 
cout<<"nttEnter Teacher id whose record you want to DELETEn"; 
cin>>n; 
system("cls"); 
while(fin.read((char*)(&t),sizeof(t))) 
{if(n==t.get_teacher_id()) 
{ f='y'; 
t.output(); 
cout<<"nCONFIRM DELETE(Y/N)n"; 
cin>>ch; 
if(ch=='y'||ch=='Y') 
{ 
cout<<"nRECORD DELETEDn"; 
getch(); 
continue; 
} 
} 
fout.write((char*)&t,sizeof(t)); 
} 
if(f!='y') 
cout<<"nteacher record not foundn"; 
fin.close(); 
fout.close(); 
remove("teacher.txt"); 
rename("temp.txt","teacher.txt"); 
} 
/**********************************STUDENT DATA INPUT 
FUNCTION**************************************************************/ 
void student::input() 
{
system("cls"); 
cout<<"Enter Roll No.n"; 
cin>>rollno; 
cout<<"nEnter Name n"; 
cin.ignore(40,'n'); 
cin.getline(name,40,'n'); 
cout<<"nFather's namen"; 
cin.getline(father_name,50,'n'); 
cout<<"nEnter Date of birthn"; 
cin.getline(dob,20,'n'); 
cout<<"nEnter Gender(M/F)n"; 
cin>>gender; 
cout<<"nEnter Contact no.n"; 
cin>>contactno; 
cout<<"nHometownn"; 
cin.ignore(50,'n'); 
cin.getline(hometown,50,'n'); 
cout<<"nEnter Coursen"; 
cin.getline(course,50,'n'); 
cout<<"nEnter year of admissionn"; 
cin>>year; 
} 
/*************************************STUDENT OUTPUT 
FUNCTION*******************************************/ 
void student::output() 
{ 
cout<<"tttSTUDENT DETAILSn" ; 
cout<<"nttRoll No.t"; 
cout<<rollno; 
cout<<"nnttName tt"; 
cout<<name; 
cout<<"nnttFather's namet"; 
cout<<father_name; 
cout<<"nnttGendertt"; 
cout<<gender<<endl; 
cout<<"nttContact No.t"; 
cout<<contactno; 
cout<<"nnttHometownt"; 
cout<<hometown; 
cout<<"nnttCoursett"; 
cout<<course<<endl; 
cout<<"nttYeartt"; 
cout<<year<<endl; 
} 
/*************************************TEACHER INPUT 
FUNCTION*******************************************/ 
void teacher::input() 
{
system("cls"); 
cout<<"Enter Teacher IDn"; 
cin>>teacher_id; 
cout<<"nEnter Name n"; 
cin.ignore(40,'n'); 
cin.getline(name,40,'n'); 
cout<<"nEnter agen"; 
cin>>age; 
cout<<"nEnter gender(M/F)n"; 
cin>>gender; 
cout<<"nEnter Subjectn"; 
cin.ignore(40,'n'); 
cin.getline(subject,70,'n'); 
cout<<"nEnter salaryn"; 
cin>>salary; 
} 
/*************************************TEACHER OUTPUT 
FUNCTION*******************************************/ 
void teacher::output() 
{ 
system("cls"); 
cout<<"ntttTEACHER DETAILSn"; 
cout<<"nttTeacher IDt"<<teacher_id; 
cout<<"nnttName tt"<<name<<"n"; 
cout<<"nttAgett"<<age<<"n"; 
cout<<"nttGendertt"<<gender<<"n"; 
cout<<"nttSubjecttt"<<subject<<"n"; 
cout<<"nttSalaryttRs."<<salary<<"n"; 
} 
int teacher::get_teacher_id() 
//Reutrning teacher id 
{return teacher_id;} 
int student::getrollno() 
//Returning student roll no. 
{return rollno;} 
int main() //MAIN 
FUNCTION 
{ 
display(); 
student s; 
teacher t; 
int c,ch; 
do{ 
system("cls"); 
cout<<"ntttMain Menu n" ; 
cout<<"nttEnter choice whose data to be maintainedn"; 
cout<<"ntt1. Studentn"; 
cout<<"ntt2. Teachern"; 
cout<<"ntt3. Exitn"; 
cin>>c; 
cout<<"n"; 
switch(c) 
{case 1:s.menu(); 
break;
case 2:t.menu(); 
break; 
case 3:cout<<"nHave a Nice Day :)n"; 
getch(); 
exit(0); 
} 
}while(1); 
getch(); 
}

More Related Content

DOCX
C++ class 12 cbse quiz programming (Compiled using Turbo C++)
DOC
Computer Science Investigatory Project class 12th
DOCX
C++ project on police station software
PDF
Computer Science class 12
DOCX
Computer Science investigatory project class 12
TXT
c++ program for Railway reservation
DOCX
Computer science project work
TXT
c++ project on restaurant billing
C++ class 12 cbse quiz programming (Compiled using Turbo C++)
Computer Science Investigatory Project class 12th
C++ project on police station software
Computer Science class 12
Computer Science investigatory project class 12
c++ program for Railway reservation
Computer science project work
c++ project on restaurant billing

What's hot (20)

PDF
Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)
PDF
81818088 isc-class-xii-computer-science-project-java-programs
PDF
Computer science Investigatory Project Class 12 C++
DOCX
C++ file
DOCX
Supermarket
DOC
Quiz using C++
DOCX
cbse 12 computer science investigatory project
DOC
Telephone billing system in c++
DOCX
computer project code ''payroll'' (based on datafile handling)
PDF
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
PDF
C++ TUTORIAL 5
PDF
C++ TUTORIAL 1
PDF
C++ TUTORIAL 2
PDF
C++ TUTORIAL 4
DOCX
Oops practical file
DOCX
Canteen management
DOCX
Investigatory Project for Computer Science
DOCX
Basic Programs of C++
DOCX
C# console programms
PDF
C++ TUTORIAL 10
Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)
81818088 isc-class-xii-computer-science-project-java-programs
Computer science Investigatory Project Class 12 C++
C++ file
Supermarket
Quiz using C++
cbse 12 computer science investigatory project
Telephone billing system in c++
computer project code ''payroll'' (based on datafile handling)
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
C++ TUTORIAL 5
C++ TUTORIAL 1
C++ TUTORIAL 2
C++ TUTORIAL 4
Oops practical file
Canteen management
Investigatory Project for Computer Science
Basic Programs of C++
C# console programms
C++ TUTORIAL 10
Ad

Viewers also liked (17)

PPTX
Musical Instrumental Management
PDF
Teacher management system guide
PPT
Instrumental delivery
DOC
Quản lý học sinh và giáo viên trong một trường phổ thông
PPTX
Assisted vaginal delivery
PPTX
Vacuum Delivery OSCE
PPTX
Instrumental vaginaldelivery...
DOCX
It sba 2015
PPTX
Vacuum extraction (ventouse)
PPTX
Forceps delivery
DOCX
Thesis computerized grading system
PPT
Instrumental deliveries
PPT
Forceps
PPTX
Operative obstetrics
PPTX
Computerized grading system chapter 1-3
PPTX
School Management System ppt
DOC
Thesis in IT Online Grade Encoding and Inquiry System via SMS Technology
Musical Instrumental Management
Teacher management system guide
Instrumental delivery
Quản lý học sinh và giáo viên trong một trường phổ thông
Assisted vaginal delivery
Vacuum Delivery OSCE
Instrumental vaginaldelivery...
It sba 2015
Vacuum extraction (ventouse)
Forceps delivery
Thesis computerized grading system
Instrumental deliveries
Forceps
Operative obstetrics
Computerized grading system chapter 1-3
School Management System ppt
Thesis in IT Online Grade Encoding and Inquiry System via SMS Technology
Ad

Similar to Student teacher database management (20)

DOCX
IN C LANGUAGE- I've been trying to finish this program for the last fe.docx
PDF
Notes for SQLite3 Usage
DOCX
Zoo management adri jovin
PDF
program on string in java Lab file 2 (3-year)
PDF
Data Structure
PDF
Bai Giang 11
PDF
DOCX
Institute management
PDF
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
DOCX
Data structures
PPT
About Go
PDF
Doubly Linked List
PDF
C program
ODP
AST Transformations at JFokus
PDF
java-introduction.pdf
PDF
DOCX
Student DATABASE MANAGeMEnT SysTEm
DOC
Project hotel on hotel management fo
IN C LANGUAGE- I've been trying to finish this program for the last fe.docx
Notes for SQLite3 Usage
Zoo management adri jovin
program on string in java Lab file 2 (3-year)
Data Structure
Bai Giang 11
Institute management
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
Data structures
About Go
Doubly Linked List
C program
AST Transformations at JFokus
java-introduction.pdf
Student DATABASE MANAGeMEnT SysTEm
Project hotel on hotel management fo

Recently uploaded (20)

PDF
System and Network Administration Chapter 2
PDF
Digital Strategies for Manufacturing Companies
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
System and Network Administraation Chapter 3
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Introduction to Artificial Intelligence
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Nekopoi APK 2025 free lastest update
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
history of c programming in notes for students .pptx
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
System and Network Administration Chapter 2
Digital Strategies for Manufacturing Companies
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
System and Network Administraation Chapter 3
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Introduction to Artificial Intelligence
Softaken Excel to vCard Converter Software.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Nekopoi APK 2025 free lastest update
Odoo Companies in India – Driving Business Transformation.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Why Generative AI is the Future of Content, Code & Creativity?
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
history of c programming in notes for students .pptx
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PTS Company Brochure 2025 (1).pdf.......
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
Which alternative to Crystal Reports is best for small or large businesses.pdf
wealthsignaloriginal-com-DS-text-... (1).pdf

Student teacher database management

  • 1. #include<iostream> #include<conio.h> #include<process.h> #include<windows.h> #include<string.h> #include<stdio.h> #include<fstream> using namespace std; void student_input(char); void student_output(char); void st_delete(char); void modify(char); void tfileinput(); void ttmodify() ; void tfileoutput(); void tdelet(); class student { int rollno , year ; // student data to be entered long long contactno; char name[40] , father_name[50] , gender ,course[50] ,dob[20] , hometown[50] ; public: student(); void input(); void output(); void smodify(); int getrollno(); void menu(); void displaylist(); }; class teacher { int teacher_id , age; float salary; //teacher data to be entered char name[40] , gender , subject[70]; public: teacher(); void input(); void output(); void tmodify(); int get_teacher_id(); void menu(); void displaylist(); }; /****************************************STUDENT CONSTRUCTOR***************************************/ student::student() { rollno=year=contactno=0; strcpy(name,"NULL"); strcpy(father_name,"NULL"); strcpy(course,"NULL"); strcpy(course,"NULL"); strcpy(dob,"NULL"); strcpy(hometown,"NULL"); gender='0'; } /********************************************TEACHER CONSTRUCTOR*******************************************************/ teacher::teacher()
  • 2. { teacher_id=age=salary=0; strcpy(name,"NULL"); gender='0'; strcpy(subject,"NULL"); } void display() { for(int i=0;i<3;i++) { cout<<"nnnttSTUDENT AND TEACHER DATABASEn"; cout<<"nnnntttLOADINGt"; for(int j=0;j<3;j++) { cout<<" . "; Sleep(350); } system("cls"); } } /***********************************STUDENT MENU********************************************************************/ void student::menu() { char c,ch,n; system("cls"); cout<<"ntEnter year whose records to be maintainednFor First year press 1nFor Second year press 2nFor Third year press 3n"; cin>>n; do { system("cls"); cout<<"ntttEnter choice:n"; cout<<"ntt1. Student Detailsn"; cout<<"ntt2. Add new recordn"; cout<<"ntt3. Modify a recordn"; cout<<"ntt4. Delete a recordn"; cout<<"ntt5. Return to main menun"; cout<<"ntt6. Exit from programn"; cin>>c; cout<<"n"; switch(c) { case '1': student_output(n); break; case '2': student_input(n); break; case '3': modify(n); break; case '4': st_delete(n); break; case '5': return; case '6': system("cls"); cout<<"nHave a nice day :)n";
  • 3. getch(); exit(0); } cout<<"ntDo you want to continuen"; cin>>ch; }while(ch=='y'||ch=='Y'); } /***********************************TEACHER MENU********************************************************************/ void teacher::menu() { char c,ch; do { system("cls"); cout<<"nttEnter choice:n"; cout<<"ntt1. Teacher Detailsn"; cout<<"ntt2. Add new recordn"; cout<<"ntt3. Modify a recordn"; cout<<"ntt4. Delete a recordn"; cout<<"ntt5. Return to main menun"; cout<<"ntt6. Exit from programn"; cin>>c;cout<<"n"; switch(c) { case '1': tfileoutput(); break; case '2': tfileinput(); break; case '3': ttmodify(); break; case '4': tdelet(); break; case '5': return ; case '6': system("cls"); cout<<"nHave a nice day :)n"; getch(); exit(0); } cout<<"ntDo you want to continuen"; cin>>ch; }while(ch=='y'||ch=='Y'); } void student_input(char q) //writing student records in file { student s; int n; ofstream fout; cout<<"nHow many records do u want to Entern"; cin>>n; switch(q) { case '1':fout.open("stud1.txt",ios::app);
  • 4. break; case '2':fout.open("stud2.txt",ios::app); break; case '3':fout.open("stud3.txt",ios::app); break; } while(n--) { s.input(); fout.write((char*)(&s),sizeof(s)); } fout.close(); } void tfileinput() //writing teacher record in file { teacher t; int n; ofstream fout; cout<<"nHow many records do u want to entern"; cin>>n; fout.open("teacher.txt",ios::app); while(n--) { t.input(); fout.write((char*)(&t),sizeof(t)); } fout.close(); } void student::displaylist() //STUDENT DISPLAY LIST { cout<<rollno<<"tt"<<name<<"n"; } void teacher::displaylist() //TEACHER DISPLAY LIST { cout<<teacher_id<<"tt"<<name<<"n"; } void student_output(char q) { system("cls"); ifstream fin; //output student student s; int f=0; switch(q) { case '1': fin.open("stud1.txt"); break; case '2': fin.open("stud2.txt");
  • 5. break; case '3': fin.open("stud3.txt"); break; } cout<<"ntttSTUDENT LISTn"<<"nRoll No. "<<"t Namen"; while(fin.read((char*)(&s),sizeof(s))) //To print student details list s.displaylist(); int n; fin.close(); switch(q) { case '1':fin.open("stud1.txt"); break; case '2':fin.open("stud2.txt"); break; case '3':fin.open("stud3.txt"); break; } cout<<"nnttEnter Roll no. whose record you want to See ('-1' to go back to previous menu)n"; cin>>n; if(n==-1) { system("cls"); return; } system("cls"); while(fin.read((char*)(&s),sizeof(s))) //To print student file details { if(n==s.getrollno()) { s.output(); f=1; } } if(f==0) cout<<"nStudent record not found !!!n"; fin.close(); } /***************************TEACHER READ FROM FILE FUNCTION******************************************************************/ void tfileoutput() { system("cls"); ifstream fin; teacher t; int f=0; fin.open("teacher.txt"); cout<<"ttTEACHER LISTnn"; cout<<"IDtt"<<"Namenn"; while(fin.read((char*)(&t),sizeof(t))) t.displaylist(); int n; fin.close(); cout<<"nnEnter Teacher ID whose record you want to see ('-1' to go back to
  • 6. previous menu)n"; cin>>n; if(n==-1) { system("cls"); return; } system("cls"); fin.open("teacher.txt"); while(fin.read((char*)(&t),sizeof(t))) { if(n==t.get_teacher_id()) { t.output(); f=1; } } if(f==0) cout<<"nEntered ID not Foundn"; fin.close(); } /************************************STUDENT MODIFY FUNCTION************************************************/ void modify(char q) { fstream fio; switch(q) { case '1':fio.open("stud1.txt"); break; case '2':fio.open("stud2.txt"); break; case '3':fio.open("stud3.txt"); break; } int no; long pos; student s; char found='f'; cout<<"nntEnter the roll no. whose record is to be modified n "; cin>>no; fio.seekg(0); while(!fio.eof()) { pos=fio.tellg(); fio.read((char *)&s, sizeof(s)); if(s.getrollno()==no) { fio.seekg(pos); system("cls"); s.output(); s.smodify(); fio.write((char*) &s, sizeof(s)); found='t'; break ; } } if(found=='f') cout<<"nntRecord not found !!n"; fio.close(); getch();
  • 7. } void student::smodify() { int srollno , syear ; // temporary data storages long long scontactno; char sname[40] , sfather_name[50] , sgender , scourse[50] , sdob[20] , shometown[50] ; cout<<"nEnter New Detailsn"; cout<<"nRoll No. (-1 to retain old one)n"; cin>>srollno; cout<<"nName ('.' to retain old one )n"; cin.ignore(40,'n'); cin.getline(sname,40,'n'); cout<<"nFather'sName ('.' to retain old one )n"; //cin.ignore(40,'n'); cin.getline(sfather_name,40,'n'); cout<<"nDate of birth ('.' to retain old one )n"; cin.getline(sdob,20,'n'); cout<<"nGender (M/F) ('.' to retain old one )n"; cin>>sgender; cout<<"nContact no. (-1 to retain old one)n"; cin>>scontactno; cout<<"nCourse ('.' to retain old one )n"; cin.ignore(50,'n'); cin.getline(scourse,50,'n'); cout<<"nHometown ('.' to retain old one )n"; //cin.ignore(50,'n'); cin.getline(shometown,50,'n'); cout<<"Year (-1 to retain old one)n"; cin>>syear; if(srollno != -1) rollno=srollno; if(scontactno != -1) contactno=scontactno; if(syear != -1) year=syear; if(strcmp(sname,".") != 0) strcpy(name,sname); if(sgender != '.') gender=sgender; if(strcmp(sfather_name,".") != 0) strcpy(father_name,sfather_name); if(strcmp(shometown,".") != 0) strcpy(hometown,shometown); if(strcmp(sdob,".") != 0)
  • 8. strcpy(dob,sdob); if(strcmp(scourse,".") != 0) strcpy(course,scourse); } /*************************************************TEACHER MODIFY FUNCTION*******************************************************/ void ttmodify() { system(" cls "); fstream fio; int no; long pos; teacher t; char found='f'; fio.open("teacher.txt",ios::in|ios::out); cout<<"nntEnter the ID whose record is to be modified n "; cin>>no; fio.seekg(0); while(!fio.eof()) { pos=fio.tellg(); fio.read((char *)&t, sizeof(t)); if(t.get_teacher_id()==no) { fio.seekg(pos); system("cls"); t.output(); t.tmodify(); fio.write((char*) &t, sizeof(t)); found='t'; break ; } } if(found=='f') cout<<"nntRecord not found !!n"; fio.close(); getch(); } void teacher::tmodify() { int tteacher_id , tage; float tsalary; //temporary teacher data to be entered char tname[40] , tgender , tsubject[70]; cout<<"nnEnter New Detailsnn"; cout<<"Enter New Teacher ID ('-1' to retain old one )n"; cin>>tteacher_id; cout<<"nName ('.' to retain old one )n"; cin.ignore(40,'n'); cin.getline(tname,40,'n'); cout<<"nAge ('-1' to retain old one )n"; cin>>tage; cout<<"nEnter gender(M/F) ('.' to retain old one )n"; cin>>tgender; cout<<"nEnter Subject ('.' to retain old one )n";
  • 9. cin.ignore(40,'n'); cin.getline(tsubject,70,'n'); cout<<"nEnter salary ('-1' to retain old one )n"; cin>>tsalary; if(tteacher_id != -1) teacher_id=tteacher_id; if(strcmp(tname,".") != 0) strcpy(name,tname); if(strcmp(tsubject,".") != 0) strcpy(subject,tsubject); if(tsalary != -1) salary=tsalary; if(tage != -1) age=tage; if(tgender != '.') gender=tgender; } /*************************************STUDENT RECORD DELETE FUNCTION FUNCTION*********************************************/ void st_delete(char q) { int n; char ch,f; student s; ifstream fin; ofstream fout; fout.open("temp.txt"); switch(q) { case '1':fin.open("stud1.txt"); break; case '2':fin.open("stud2.txt"); break; case '3':fin.open("stud3.txt"); break; } cout<<"nEnter roll no. whose record you want to DELETEn"; cin>>n; system("cls"); while(fin.read((char*)(&s),sizeof(s))) { if(n==s.getrollno()) { f='y'; s.output(); cout<<"nCONFIRM DELETE(Y/N)n"; cin>>ch; if(ch=='y'||ch=='Y') { cout<<"nRECORD DELETEDn"; getch(); continue; }
  • 10. } fout.write((char*)&s,sizeof(s)); } if(f!='y') cout<<"nstudent record not foundn"; fin.close(); fout.close(); switch(q) { case '1':remove("stud1.txt"); rename("temp.txt","stud1.txt"); break; case '2':remove("stud2.txt"); rename("temp.txt","stud2.txt"); break; case '3':remove("stud3.txt"); rename("temp.txt","stud3.txt");; break; } } /*************************************TEACHER RECORD DELETE FUNCTION FUNCTION*********************************************/ void tdelet() { int n; char ch,f; teacher t; ifstream fin; ofstream fout; fin.open("teacher.txt"); fout.open("temp.txt"); cout<<"nttEnter Teacher id whose record you want to DELETEn"; cin>>n; system("cls"); while(fin.read((char*)(&t),sizeof(t))) {if(n==t.get_teacher_id()) { f='y'; t.output(); cout<<"nCONFIRM DELETE(Y/N)n"; cin>>ch; if(ch=='y'||ch=='Y') { cout<<"nRECORD DELETEDn"; getch(); continue; } } fout.write((char*)&t,sizeof(t)); } if(f!='y') cout<<"nteacher record not foundn"; fin.close(); fout.close(); remove("teacher.txt"); rename("temp.txt","teacher.txt"); } /**********************************STUDENT DATA INPUT FUNCTION**************************************************************/ void student::input() {
  • 11. system("cls"); cout<<"Enter Roll No.n"; cin>>rollno; cout<<"nEnter Name n"; cin.ignore(40,'n'); cin.getline(name,40,'n'); cout<<"nFather's namen"; cin.getline(father_name,50,'n'); cout<<"nEnter Date of birthn"; cin.getline(dob,20,'n'); cout<<"nEnter Gender(M/F)n"; cin>>gender; cout<<"nEnter Contact no.n"; cin>>contactno; cout<<"nHometownn"; cin.ignore(50,'n'); cin.getline(hometown,50,'n'); cout<<"nEnter Coursen"; cin.getline(course,50,'n'); cout<<"nEnter year of admissionn"; cin>>year; } /*************************************STUDENT OUTPUT FUNCTION*******************************************/ void student::output() { cout<<"tttSTUDENT DETAILSn" ; cout<<"nttRoll No.t"; cout<<rollno; cout<<"nnttName tt"; cout<<name; cout<<"nnttFather's namet"; cout<<father_name; cout<<"nnttGendertt"; cout<<gender<<endl; cout<<"nttContact No.t"; cout<<contactno; cout<<"nnttHometownt"; cout<<hometown; cout<<"nnttCoursett"; cout<<course<<endl; cout<<"nttYeartt"; cout<<year<<endl; } /*************************************TEACHER INPUT FUNCTION*******************************************/ void teacher::input() {
  • 12. system("cls"); cout<<"Enter Teacher IDn"; cin>>teacher_id; cout<<"nEnter Name n"; cin.ignore(40,'n'); cin.getline(name,40,'n'); cout<<"nEnter agen"; cin>>age; cout<<"nEnter gender(M/F)n"; cin>>gender; cout<<"nEnter Subjectn"; cin.ignore(40,'n'); cin.getline(subject,70,'n'); cout<<"nEnter salaryn"; cin>>salary; } /*************************************TEACHER OUTPUT FUNCTION*******************************************/ void teacher::output() { system("cls"); cout<<"ntttTEACHER DETAILSn"; cout<<"nttTeacher IDt"<<teacher_id; cout<<"nnttName tt"<<name<<"n"; cout<<"nttAgett"<<age<<"n"; cout<<"nttGendertt"<<gender<<"n"; cout<<"nttSubjecttt"<<subject<<"n"; cout<<"nttSalaryttRs."<<salary<<"n"; } int teacher::get_teacher_id() //Reutrning teacher id {return teacher_id;} int student::getrollno() //Returning student roll no. {return rollno;} int main() //MAIN FUNCTION { display(); student s; teacher t; int c,ch; do{ system("cls"); cout<<"ntttMain Menu n" ; cout<<"nttEnter choice whose data to be maintainedn"; cout<<"ntt1. Studentn"; cout<<"ntt2. Teachern"; cout<<"ntt3. Exitn"; cin>>c; cout<<"n"; switch(c) {case 1:s.menu(); break;
  • 13. case 2:t.menu(); break; case 3:cout<<"nHave a Nice Day :)n"; getch(); exit(0); } }while(1); getch(); }