Beruflich Dokumente
Kultur Dokumente
School Seal
ACKNOWLEDGEMENT
We would like to express our deep gratitude
to Mrs. B.Sumathi, Our computer science teacher for
helping and guiding us in completing this project
successfully.
CLASS :
PROJECT NAME :
SCHOOL SEAL :
The project “question paper” prepares question paper covering the
following lessons
1. Structure
2. Class & Object
3. Constructor & Destructor
4. Function Overloading
5. Inheritance
6. Implementation of data structure
7. Boolean Algebra
8. Files Organization
The program has been stored in the project in the file ‘project’ &
four disk files are used in the program are
1. On1.dat
2. To2.dat
3. Thee3.dat
4. Fiv5.dat
HARDWARE SPECIFICATION
• Memory: 984 KB
• Microprocessor:1.2
• Hard disk:40 GB
• Printer: hp Laser printer
SOFTWARE SPECIFICATION
2. Try file:
Fields
• Int no
• Char ques
Class required:
Question
Operation:
1. Void one() :
One mark questions are stored.
2. Void two () :
Two mark question are stored.
3. Void three () :
Three mark question are stored.
4. Void four () :
Six mark question are stored.
Question selection :
1. From the disk file ’on1.dat’ required
number of mark question are selected.
2. From the disk file ‘to2.dat’ required
number of two marks question are
selected.
3. From the disk file ‘thee3.dat’ required
number of three marks question are
selected .
4. From the disk file ‘fiv5.dat’ required
number of five marks question are
selected.
The disk file1.dat is assigned to file variable
Step 5:
Creation
a) Option is selection for one mark
Read the number of question to be created for one mark
Step 6:
Repeat step 5 for two marks, three marks & six marks
Exit
Step 7:
While ob
Try file
Step 8:
Creation & display of try file
Step 9:
Open “on1.dat” file 1 one mark
Set r=rand () %21
If (r=0) repeat step 9
Else set a [0]=r, for (I=1 to 5)
Step 10:
Set r=rand (_) %21
If (r=0) repeat step 10
Else if (a[i]=r)repeat step 10
Else set j=j+1
Step 11:
Set a [i]=r, for (I=0 to 5)
If (a[i]>a[j])
Set temp=a[i]
a[i]=a[j]
a[j]=temp, set i=0
read file1();
Step 12:
If(a[i]=bank.n)
Set strcpy(paper(==L1),bank.ques)
Set i=i+1
Step 13:
For(i=0 to 11)
Print ++q1
Print paper(i),100:
Step 14:
Close File
Step 15:
Repeat step 9th and 13th for two marks, three marks and five
marks.
Step 16:
Compile and run the program.
For output.
Step 17:
Exit.
Start
Input option
Enter the option
1.Creation and display
2.Selection and display
If Option = Stop
=0
If Option
==1 S
Input number
of Case
Case
question
Case
Mark
and3:
4:
1:marks
2:
three
four
=0
one
two 0
00 2CD
A
B
Yes
Input marks 2
X A
Open a file
File.open(“one.d
ata”)
For(i=0
; i=20;
i++)
For(i=0
; i=20;
i++)
Write q getdata
file.write
Write q getdata
file.write
While(file
file.read
Write
Read q.getdata
) q.display
X K
file.read
file.write
file.close
file.read
X
Open a file
File.open(to2.dat)
For(i
=1;i<
20;i+
+)
Input q .getdata ()
File .write ()
File. read ()
Whil
e
(file)
Read q.display
file. read
File. Close ()
X
X
Open a file
File.open(“three3.dat”)
For(i=
1;i=20;
i++)
Write q. getdata
File . write
File.read
While
(file)
Read q. display
File.read
File.close
X
A
Open a file
File.open(“five.da
t”)
Write g.getdata
file.write()
File.read()
While
(file)
Read q.display
file.read K
X
X
Input option
select and
display
Two mark
question is
selected and
stored in an array
X
X
Stop
#include<iostream.h>
#include<stdio.h>
#include<fstream.h>
#include<string.h>
class question
{
public:
int no;
char ques[100];
void getdata();
void display();
};
void question::getdata()
{
cout<<"\n\t Enter the Question no. "<<endl;
cin>>no;
cout<<"\n\t Enter the question"<<endl;
gets(ques);
}
void question::display()
{
cout<<"\n\t Question "<<no<<" "<<ques<<endl;
}
question q;
void one();
void two();
void three();
void five();
void main()
{
int mark;
while(mark!=0)
{
switch(mark)
{
case 1:
{
one();
}
case 2:
{
two();
}
case 3:
{
three();
}
case 4:
{
five();
}
break;
}//end of switch
cout<<"\n\t Enter the 1:one mark, 2:two mark, 3:three mark,
4:five mark"<<endl;
cin>>mark;
}//end of while
}//end of main
void one()
{
fstream file;
file.open("on1.dat",ios::app|ios::in|ios::out|ios::binary);
for(int i=1;i<2;i++)
{
q.getdata();
file.write((char* )&q,sizeof(q));
}
file.seekg(0,ios::beg);
file.read((char *)&q,sizeof(q));
while(file)
{
q.display();
file.read((char *)& q,sizeof(q));
cout<<"\n\t Enter a key to continue"<<endl;
char ch;
cin>>ch;
}
file.close();
return;
}
void two()
{
fstream file;
file.open("to2.dat",ios::app|ios::in|ios::out|ios::binary);
for(int i=1;i<2;i++)
{
q.getdata();
file.write((char*)&q,sizeof(q));
}
file.seekg(0,ios::beg);
file.read((char *)&q,sizeof(q));
while(file)
{
q.display();
file.read((char *)& q,sizeof(q));
cout<<"\n\t Enter a key to continue"<<endl;
char ch;
cin>>ch;
file.read((char *)& q,sizeof(q));
}
file.close();
return;
}
void three()
{
fstream file;
file.open("three3.dat",ios::app|ios::in|ios::out|ios::binary);
for(int i=1;i<2;i++)
{
q.getdata();
file.write((char *)&q,sizeof(q));
}
file.seekg(0,ios::beg);
file.read((char *)&q,sizeof(q));
while(file)
{
q.display();
char ch;
cout<<"\n\t Press a key to continue"<<endl;
cin>>ch;
file.read((char*)& q,sizeof(q));
}
file.close();
return;
}
void five()
{
fstream file;
file.open("five5.dat",ios::app|ios::in|ios::out|ios::binary);
for(int i=1;i<2;i++)
{
q.getdata();
file.write((char *)&q,sizeof(q));
}
file.seekg(0,ios::beg);
file.read((char *)&q,sizeof(q));
while(file)
{
q.display();
char ch;
cout<<"\n\t Press a key to continue"<<endl;
cin>>ch;
file.read((char *)& q,sizeof(q));
}
file.close();
return;
}
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<fstream.h>
#include<stdlib.h>
#include<stdio.h>
class question
{
public:
int n;
char ques[100];
void inputdata();
void display();
};
void question::inputdata()
{
cin>>n;
cin>>ques;
}
void question::display()
{
puts(ques);
}
int t1=-1,t2=-1,t3=-1;
question bank;
char paper[10][100],paper2[5][100],paper3[5]
[100],paper4[5][100];
void heading();
void one();
void two();
void three();
void five();
question ar1[10],ar2[10],ar3[10];
fstream file1,file2;
int on;
int l1=-1,l2=-1,l3=-1,l4=-1;
void main()
{
heading();
one();
two();
three();
five();
}
void heading()
{
clrscr();
cout<<"\n\t KOLA SARASWATHI VAISHNAV
SENIOR SECONDARY SCHOOL "<<endl;
cout<<"\n\t IV MONTHLY TEST
"<<endl;
cout<<"\n\t XII STD 35
MARKS "<<endl;
cout<<"\n\t 7/1/11 1 1/2
Hour "<<endl;
}
void one()
{
cout<<"\n\t ANSWER THE FOLLOWING ONE MARK
QUESTIONS (1*4=4) "<<endl;
cout<<"\n\t
"<<endl;
int a[10];
file1.open("on1.dat",ios::app|ios::in|ios::out|ios::binary);
file1.seekg(0);
int r;
one1:r=rand()%21;
if(r==0)
goto one1;
else
a[0]=r;
for(int i=1;i<=5;i++)
{
start:r=rand()%21;
if(r==0)
goto start;
int j=0;
while(j<i)
{
if(a[j]==r)
goto start;
else
j=j+1;
}//end of while
a[i]=r;
}//end of for
for(i=0;i<5;i++)
{
for(int j=i+1;j<5;j++)
{
if(a[i]>a[j]);
{
int temp=a[i];
a[i]=a[j];
a[j]=temp;
}//end of if
}//end of j loop
}//end of i loop
i=0;
file1.seekg(0);
file1.read((char *)&bank,sizeof(bank));
while(file1)
{
if(a[i]==bank.n)
{
strcpy(paper[++l1],bank.ques);
i+=1;
}//End of if
file1.read((char *)& bank, sizeof(bank));
}//end of while
int q1=0;
for(i=1;i<=4;i++)
{
cout<<"\n\t "<<++q1<<" ";
cout.write(paper[i],100)<<endl;
}//enf of for
char ch;
cout<<"\n\t Enter any key to continue";
cin>>ch;
clrscr();
file1.close();
return;
}
void two()
{
cout<<"\n\t ANSWER THE FOLLOWING TWO MARK
QUESTIONS (2*5=10) "<<endl;
cout<<"\n\t
"<<endl;
int b[10];
file1.open("to2.dat",ios::app|ios::in|ios::out|ios::binary);
file1.seekg(0);
int r;
one1:r=rand()%21;
if(r==0)
goto one1;
else
b[0]=r;
for(int i=1;i<=5;i++)
{
start:r=rand()%21;
if(r==0)
goto start;
int j=0;
while(j<i)
{
if(b[j]==r)
goto start;
else
j=j+1;
}//end of while
b[i]=r;
}//end of for
for(i=0;i<4;i++)
{
for(int j=i+1;j<5;j++)
{
if(b[i]>b[j]);
{
int temp=b[i];
b[i]=b[j];
b[j]=temp;
}//end of if
}//end of j loop
}//end of i loop
i=0;
file1.seekg(0);
file1.read((char *)&bank,sizeof(bank));
while(file1)
{
if(b[i]==bank.n)
{
strcpy(paper2[++l2],bank.ques);
i+=1;
}
file1.read((char *)& bank, sizeof(bank));
}
int q2=0;
for(i=1;i<=5;i++)
{
cout<<"\n\t "<<++q2<<" ";
cout.write(paper2[i],100)<<endl;
}
file1.close();
char ch;
cout<<"\n\t Enter any key to continue";
cin>>ch;
clrscr();
return;
}
void three()
{
cout<<"\n\t ANSWER THE FOLLOWING THREE MARK
QUESTIONS (3*5=15) "<<endl;
cout<<"\n\t
"<<endl;
int c[10];
file1.open("three3.dat",ios::app|ios::in|ios::out|ios::binary);
file1.seekg(0);
int r;
one1:r=rand()%21;
if(r==0)
goto one1;
else
c[0]=r;
for(int i=1;i<=5;i++)
{
start:r=rand()%21;
if(r==0)
goto start;
int j=0;
while(j<i)
{
if(c[j]==r)
goto start;
else
j=j+1;
}//end of while
c[i]=r;
}//end of for
for(i=0;i<4;i++)
{
for(int j=i+1;j<5;j++)
{
if(c[i]>c[j]);
{
int temp=c[i];
c[i]=c[j];
c[j]=temp;
}//end of if
}//end of j loop
}//end of i loop
i=0;
file1.seekg(0);
file1.read((char *)&bank,sizeof(bank));
while(file1)
{
if(c[i]==bank.n)
{
strcpy(paper3[++l3],bank.ques);
i+=1;
}
file1.read((char *)& bank, sizeof(bank));
}
int q3=0;
for(i=1;i<=5;i++)
{
cout<<"\n\t "<<++q3<<" ";
cout.write(paper3[i],100)<<endl;
}
file1.close();
char ch;
cout<<"\n\t Enter any key to continue";
cin>>ch;
clrscr();
return;
}
void five()
{
cout<<"\n\t ANSWER THE FOLLOWING SIX MARK
QUESTIONS (6*1=6) "<<endl;
cout<<"\n\t
"<<endl;
int d[10];
file1.open("fiv5.dat",ios::app|ios::in|ios::out|ios::binary);
file1.seekg(0);
int r;
one1:r=rand()%21;
if(r==0)
goto one1;
else
d[0]=r;
for(int i=1;i<=1;i++)
{
start:r=rand()%21;
if(r==0)
goto start;
int j=0;
while(j<i)
{
if(d[j]==r)
goto start;
else
j=j+1;
}//end of while
d[i]=r;
}//end of for
for(i=0;i<1;i++)
{
for(int j=i+1;j<1;j++)
{
if(d[i]>d[j]);
{
int temp=d[i];
d[i]=d[j];
d[j]=temp;
}//end of if
}//end of j loop
}//end of i loop
i=0;
file1.seekg(0);
file1.read((char *)&bank,sizeof(bank));
while(file1)
{
if(d[i]==bank.n)
{
strcpy(paper4[++l4],bank.ques);
i+=1;
}
file1.read((char *)& bank, sizeof(bank));
}
int q4=0;
for(i=1;i<=1;i++)
{
cout<<"\n\t "<<++q4<<" ";
cout.write(paper4[i],100)<<endl;
}
file1.close();
char ch;
cout<<"\n\t Enter any key to continue";
cin>>ch;
clrscr();
return;
}
I UNIT TEST
7.1.2011 1 ½ HOUR