Computer Science Project On Student Management System
Computer Science Project On Student Management System
CERTIFICATE
This is to certify that the Computer Science Investigatory
Project entitled “Student Management System” submitted
to Department of Computer Science, St.Xavier’s High
School,Khandagiri,Bhubaneswar
has been successfully completed by Soumya Suman
Padhiary of Class XII-A in partial fulfilment of curriculum
of Central Board of Secondary Education(CBSE) leading to
the award of Annual Examination of the academic year
2019-20.
Student Signature
ACKNOWLEDGEMENT
Student Signature
INDEX
SL NO. TOPIC PAGE NO.
1 Header Files Used
2 Files Generated
3 Working description
4 Code
5 Output Screen
6 Bibliography
HEADER FILES USED
1. iostream.h – For cin and cout
2. fstream.h – For file handling
3. stdio.h – For standard input/output operations
4. string.h – For string handling
5. stdlib.h – For functions contained in standard library
FILES GENERATED
DATA FILES
stu.dat
temp.dat
PROGRAM FILE
studentmanagementsystem.cpp
OBJECT FILE
studentmanagementsystem.obj
EXECUTION FILE
studentmanagementsystem.cpp
WORKING DESCRIPTION
The project is “STUDENT MANAGEMENT SYSTEM”.
In this project we can do the following things:-
Add records
Search and display a record
Insert a record
Modify a record
Delete a record
#include<fstream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int roll;
char name[25];
int Class;
float marks;
char grade;
char father[25];
char mother[25];
char area[25];
char city[30];
int PIN;
public:
void getdata()
cin>>roll;
cin>>Class;
cout<<"Name: ";
cin>>name;
cin>>marks;
if(marks>=75)
grade='a';
else if(marks>=60)
grade='b';
else if(marks>=50)
grade='c';
else if(marks>=40)
grade='d';
else grade='f';
cin>>father;
cin>>mother;
cin>>area;
cin>>city;
cin>>PIN;
void putdata()
{
cout<<"Area: ";
cout<<area<<endl;
cout<<"City: "<<city<<endl;
cout<<endl<<endl;
int getrno()
return roll;
void modify();
};
void student::modify()
cout<<"Rollno :"<<roll<<endl;
int Cl;
float mks;
char fther[25];
char mther[25];
char areaa[25];
char cty[30];
int PN;
cin >>nm;
cin >>Cl;
cin>>mks;
cout << "New Father Name :(Enter '.' to retain old one)";
cin >>fther;
cout << "New Mother Name :(Enter '.' to retain old one)";
cin >>mther;
cin >>areaa;
cin >>cty;
cin >>PN;
if(strcmp(nm,".")!=0)
strcpy(name,nm);
if(strcmp(fther,".")!=0)
strcpy(father,fther);
if(strcmp(mther,".")!=0)
strcpy(mother,mther);
if(strcmp(areaa,".")!=0)
strcpy(area,areaa);
if(strcmp(cty,".")!=0)
strcpy(city,cty);
if(Cl!=-1)
Class=Cl;
if(PN!=-1)
PIN=PN;
if(mks!=-1)
{marks=mks;
else grade='F';
int main()
{ int choice,n;
for(int k=0;;k++)
cout<<"6.EXIT\n";
cout<<"WHAT DO YOU WANT TO DO??(add records if not added)";
cin>>choice;
cin>>n;
student s[n];
ofstream ofs;
ofs.open("stu.dat",ios::out|ios::binary);
for(int i=0;i<n;i++)
s[i].getdata();
ofs.write((char*)&s[i],sizeof(s[i]));
cout<<endl;
ofs.close();
ifstream ifs;
ifs.open("stu.dat",ios::in|ios::binary);
ifs.seekg(0);
for(int i=0;i<n;i++)
ifs.read((char*)&s[i],sizeof(s[i]));
s[i].putdata();
}
ifs.close();
student st;
int rn;
char found='n';
ifstream fi("stu.dat",ios::in);
cin>>rn;
while(!fi.eof())
fi.read((char*)&st,sizeof(st));
if(st.getrno()==rn)
st.putdata();
found='y';
break;
if(found=='n')
fi.close();
student s1,stud;
ifstream fi("stu.dat",ios::in|ios::binary);
ofstream fo("temp.dat",ios::out|ios::binary);
char last='y';
s1.getdata();
while(!fi.eof())
fi.read((char*)&stud,sizeof(stud));
if(s1.getrno()<=stud.getrno())
fo.write((char*)&s1,sizeof(s1));
last='n';
break;
else
fo.write((char*)&stud,sizeof(stud));
if(last=='y')
fo.write((char*)&s1,sizeof(s1));
else if(!fi.eof())
while(!fi.eof())
{fi.read((char*)&stud,sizeof(stud));
fo.write((char*)&stud,sizeof(stud));
}
fi.close();
fo.close();
remove("stu.dat");
rename("temp.dat","stu.dat");
fi.open("stu.dat",ios::in);
while(!fi.eof())
fi.read((char*)&stud,sizeof(stud));
if(fi.eof())
break;
stud.putdata();
fi.close();
{student s3,stud2;
fstream fio("stu.dat",ios::in|ios::out|ios::binary);
cin >>rno;
while(!fio.eof())
pos=fio.tellg();
fio.read((char*)&s3,sizeof(s3));
if(s3.getrno()==rno)
{s3.modify();
fio.seekg(pos);
fio.write((char*)&s3,sizeof(s3));
found='t';
break;
if(found=='f')
fio.seekg(0);
while(!fio.eof())
fio.read((char*)&stud2,sizeof(stud2));
if(fio.eof())break;
stud2.putdata();
fio.close();
student s2,stud1;
ifstream fio("stu.dat",ios::in|ios::binary);
int rno;
cin >>rno;
while(!fio.eof())
{fio.read((char*)&s2,sizeof(s2));
if(s2.getrno()==rno)
{s2.putdata();
found='t';
cin>>confirm;
if(confirm=='n')
file.write((char*)&s2, sizeof(s2));
else
file.write((char*)&s2,sizeof(s2));
if(found=='f')
fio.close();
file.close();
remove("stu.dat");
rename("temp.dat","stu.dat");
fio.open("stu.dat",ios::in);
fio.seekg(0);
while(!fio.eof())
fio.read((char*)&stud1,sizeof(stud1));
if(fio.eof()) break;
stud1.putdata();
}
fio.close();
if(choice==6)
exit(0);
return 0;
}
OUTPUT
Adding records to the file
Inserting a record
Inserting a record
Modifying a record
Deleting a record
BIBLIOGRAPHY
Computer Science with C++ by Sumita Arora
en.wikipedia.com
google.com