Escolar Documentos
Profissional Documentos
Cultura Documentos
VIDYA MANDIR
COMPUTER SCIENCE
INVESTIGATORY PROJECT
Name : Bharathwaj S
Class : XII
Roll No :
Page 1 of 26
ACKNOWLEDGEMENT
Page 2 of 26
INDEX
Contents
Page
No.
1.
2.
3.
4.
5.
6.
7.
Abstract..2
Introduction...........3
System Requirements..4
Coding..5
Output Screenshots20
Conclusion.24
Bibliography.25
Page 3 of 26
ABSTRACT
The project entitled Online Examination System is developed
using the programming language C++.
The teacher can manage the examinations details present for the
students.
The project aims at simplifying a teachers job of creating and
checking the results of th students. It also helps students access tests easily and
get immediate test reports.
Page 4 of 26
INTRODUCTION
Page 5 of 26
SYSTEM REQUIREMENTS
Hardware:
1. Processor : IntelCore2 Duo CPU E4500@ 2.20 GHz
2. RAM : 1024 MB
3. Hard Disk : 150GB
Software:
1. Windows XP Operating system
2. Turbo C++
Page 6 of 26
CODING
#include<fstream.h>
#include<dos.h>
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class EXAM
{
struct QUESTION
{
char que[500];
char fians[100];
char sans[100];
char tans[100];
char foans[100];
char nans[100];
int ans[5],anss;
}question;
struct SECURITY
{
char uname[20];
Page 7 of 26
char pass[20];
}security;
fstream file;
public:
void writequestion();
void readdata();
void takeexam();
void writenewexam();
void makeusername();
void changepassword();
int checkpassword();
int returnminute();
};
void EXAM::makeusername()
{
file.open("examsecurity.txt",ios::binary|ios::in|ios::out);
file.seekp(0L,ios::beg);
cout<<"\n ENTER THE USERNAME :"<<" ";
gets(security.uname);
cout<<"\n ENTER THE PASSWORD :"<<" ";
gets(security.pass);
file.write((char *)&security,sizeof(security));
file.close();
}
Page 8 of 26
void EXAM::changepassword()
{
char ouname[20],opass[20];
file.open("examsecurity.txt",ios::binary|ios::in|ios::out);
file.seekg(0L,ios::beg);
cout<<"\n ENTER THE OLD USERNAME :"<<" ";
gets(ouname);
cout<<"\n ENTER OLD PASSWORD :" <<" ";
gets(opass);
file.read((char *)&security,sizeof(security));
if((strcmp(ouname,security.uname)==0)&&(strcmp(opass,security.pass)==0))
{
file.seekp(0L,ios::beg);
cout<<"\n ENTER NEW USERNAME :"<<" ";
gets(security.uname);
cout<<"\n ENTER THE PASSWORD :"<<" ";
gets(security.pass);
file.write((char *)&security,sizeof(security));
}
else
cout<<"\n USER DOES NOT EXIST ";
file.close();
}
int EXAM::checkpassword()
Page 9 of 26
{
int flag;
char ouname[20],opass[20];
file.open("examsecurity.txt",ios::binary|ios::in|ios::out);
file.seekg(0L,ios::beg);
cout<<"\n ENTER THE USERNAME :"<<" ";
gets(ouname);
cout<<"\n ENTER PASSWORD :" <<" ";
gets(opass);
file.read((char *)&security,sizeof(security));
if((strcmp(ouname,security.uname)==0)&&(strcmp(opass,security.pass)==0))
flag=1;
else
flag=0;
file.close();
if(flag==1)
return 1;
else
return 0;
}
void EXAM::writequestion()
{
file.open("exam.txt",ios::binary|ios::in|ios::out);
Page 10 of 26
file.seekp(0L,ios::end);
cout<<"\n Enter the question:"<<" ";
gets(question.que);
cout<<"\n Enter the first option:"<<" ";
gets(question.fians);
cout<<"\n Is it correct answer? \n if yes press 1 else 2"<<" ";
cin>>question.ans[0];
if(question.ans[0]==1)
question.anss=question.ans[0];
cout<<"\n Enter the second option:"<<" ";
gets(question.sans);
cout<<"\n Is it correct answer? \n if yes press 1 else 2"<<" ";
cin>>question.ans[1];
if(question.ans[1]==1)
question.anss=question.ans[1];
cout<<"\n Enter the third option:"<<" ";
gets(question.tans);
cout<<"\n Is it correct answer? \n if yes press 1 else 2"<<" ";
cin>>question.ans[2];
if(question.ans[2]==1)
question.anss=question.ans[2];
cout<<"\n Enter the fourth option:"<<" ";
gets(question.foans);
cout<<"\n Is it correct answer? \n if yes press 1 else 2"<<" ";
Page 11 of 26
cin>>question.ans[3];
if(question.ans[3]==1)
question.anss=question.ans[3];
cout<<"\n Enter last option:"<<" ";
gets(question.nans);
cout<<"\n Is it correct answer? \n if yes press 1 else 2"<<" ";
cin>>question.ans[4];
if(question.ans[4]==1)
question.anss=question.ans[4];
file.write((char *)&question,sizeof(question));
cout<<"\n Questions Created Successfully... ";
file.close();
clrscr();
}
void EXAM::writenewexam()
{
file.open("exam.txt",ios::binary|ios::in|ios::out);
file.seekp(0L,ios::beg);
cout<<"\n Enter the question:"<<" ";
gets(question.que);
cout<<"\n Enter the first option:"<<" ";
gets(question.fians);
cout<<"\n Is it correct answer? \n if yes press 1 else 2"<<" ";
cin>>question.ans[0];
Page 12 of 26
if(question.ans[0]==1)
question.anss=question.ans[0];
cout<<"\n Enter the second option:"<<" ";
gets(question.sans);
cout<<"\n Is it correct answer? \n if yes press 1 else 2"<<" ";
cin>>question.ans[1];
if(question.ans[1]==1)
question.anss=question.ans[1];
cout<<"\n Enter the third option:"<<" ";
gets(question.tans);
cout<<"\n Is it correct answer? \n if yes press 1 else 2"<<" ";
cin>>question.ans[2];
if(question.ans[2]==1)
question.anss=question.ans[2];
cout<<"\n Enter the fourth option:"<<" ";
gets(question.foans);
cout<<"\n Is it correct answer? \n if yes press 1 else 2"<<" ";
cin>>question.ans[3];
if(question.ans[3]==1)
question.anss=question.ans[3];
cout<<"\n Enter last option:"<<" ";
gets(question.nans);
cout<<"\n Is it correct answer? \n if yes press 1 else 2"<<" ";
cin>>question.ans[4];
Page 13 of 26
if(question.ans[4]==1)
question.anss=question.ans[4];
file.write((char *)&question,sizeof(question));
cout<<"\n New Exam Created Successfully... ";
file.close();
clrscr();
}
void EXAM::readdata()
{
int count;
file.open("exam.txt",ios::binary|ios::in|ios::out);
file.seekg(0L,ios::beg);
while(file.read((char *)&question,sizeof(question)))
{
count=0;
cout<<"\n"<<question.que<<"\n";
cout<<"1)"<<question.fians;
cout<<"\n2)"<<question.sans;
cout<<"\n3)"<<question.tans;
cout<<"\n4)"<<question.foans;
cout<<"\n5)"<<question.nans;
for(int i=0;i<5;i++)
{
Page 14 of 26
++count;
if(question.ans[i]==1)
cout<<"\n Answer is option "<<count;
}
cout<<"\n--------\n";
}
file.close();
}
void EXAM::takeexam()
{
int min;
int ch,p=0,count,c;
min=returnminute();
file.open("exam.txt",ios::binary|ios::in|ios::out);
file.seekg(0L,ios::beg);
while(file.read((char *)&question,sizeof(question)))
{
count=0;
cout<<"\n"<<question.que<<"\n";
cout<<"1)"<<question.fians;
cout<<"\n2)"<<question.sans;
cout<<"\n3)"<<question.tans;
cout<<"\n4)"<<question.foans;
Page 15 of 26
cout<<"\n5)"<<question.nans;
for(int i=0;i<5;i++)
{
++count;
if(question.ans[i]==1)
{
c=count;
}
}
cout<<"\n Enter your answer number:"<<" ";
cin>>ch;
if(ch==c)
{
++p;
}
cout<<"\n--------";
clrscr();
cout<<"
int EXAM::returnminute()
{
struct time t;
gettime(&t);
printf("Time is: %2d:%02d:%02d.%02d\n",
t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);
return(t.ti_min);
}
void main()
{
int ch,ch1;
EXAM exam;
clrscr();
cout<<"
cout<<" \t\t\t-------------------------------"<<endl;
cout<<" \t\t\t|| WELCOME TO YOUR DASHBOARD || ";
do
{
cout<<"\n 1.Teacher \n 2.Student \n 3.Exit";
cout<<"\n Enter your choice:"<<" ";
cin>>ch;
Page 17 of 26
switch(ch)
{
case 1:
clrscr();
cout<<"
\n\t\t
cout<<" \t\t\t-------------------------------"<<endl;
if(exam.checkpassword())
clrscr();
cout<<" \n\n\t";
do
{
cout<<"\t\t|| ONLINE EXAMINATION SYSTEM ||"<<endl;
cout<<"\t\t\t-------------------------------"<<endl;
cout<<"\n\t\t\t TEACHER HUB"<<endl;
cout<<"\t\t\t --------------";
cout<<"\n1.Want to add question\n2.Read questions\n3.Create new
exam\n4.Create new Teacher ID\n5.Update existing Teacher ID\n6.Exit";
cout<<"\nEnter your choice:"<<" ";
cin>>ch1;
switch(ch1)
{
case 1:
clrscr();
cout<<"
cout<<" \t\t\t-------------------------------"<<endl;
Page 18 of 26
exam.writequestion();
break;
case 2:
clrscr();
cout<<"
cout<<" \t\t\t-------------------------------"<<endl;
exam.readdata();
break;
case 3:
clrscr();
cout<<"
cout<<" \t\t\t-------------------------------"<<endl;
exam.writenewexam();
break;
case 4:
clrscr();
cout<<"
cout<<" \t\t\t-------------------------------"<<endl;
exam.makeusername();
break;
case 5:
clrscr();
cout<<"
cout<<" \t\t\t-------------------------------"<<endl;
Page 19 of 26
exam.changepassword();
break;
case 6:
clrscr();
cout<<"
cout<<" \t\t\t-------------------------------"<<endl;
clrscr();
break;
}
}while(ch1!=6);
break;
case 2:
clrscr();
cout<<"
cout<<" \t\t\t-------------------------------"<<endl;
cout<<"\n EXAM STARTS ...\n ALL THE BEST !! "<<" "<<endl;
exam.takeexam();
cout<<" \n END OF EXAM ... "<<endl;
break;
case 3:
break;
}
}while(ch!=3);
}
Page 20 of 26
//
Output screens
Page 21 of 26
Page 22 of 26
Page 23 of 26
Page 24 of 26
CONCLUSION
The online examination system has many advantages of which some are :
Eco Friendly
Efficient
Quick results
Reduces manual labour
Security
Page 25 of 26
BIBLIOGRAPHY
1.
Page 26 of 26