Friday, March 3, 2017

Search Student From Exam Result Sheet Source Code In C++

#include<fstream.h>
#include<iostream.h>
#include<conio.h>
#include <string.h>
class pro
{
public:
int done();
};
int pro::done()
{
char str[2000];
//char roll[100][10];
char r[10];
int sum=0;
int find=0;
cout<<"Enter roll to search:";
cin>>r;
fstream file_op("1.txt",ios::in);
int i=0,j=1;
while(file_op >> str)
{
if(file_op.eof())
{
find=0;
break;
}
if(i%7==0)
{
if(strcmp(r,str)==0)
{
cout<<"\n\nRoll \tName \tpos\tphy\tChem\tEng\tMath\tTotal\n"; cout<<"------------------------------------------------\
------------------\n";
find=1;
cout << str<<"\t" ;
//cout<<"yes found";
while(file_op >> str)
{
cout << str<<"\t" ;
if(j>=3 && j<=6)
{
int d=1;
for(int i=strlen(str)-1;i>=0;i--)
{
sum+=(str[i]-48)*d;
d*=10;
}
}
if(j==6)
break;
j++;
}
}
}
if(find==1)
break;
i++;
}
if(find==1)
cout<<sum;
else
cout<<"not found!";
file_op.close();
return 0;
}
void main(void)
{
pro P;
clrscr();
P.done();
getch();
}

////////////////////////////////////////////////////////////////////////////
You must include a file "1.text",You can include data in this file "1.text" like below,
0407016
saiful
1
50
65
45
89
0407021
Firoj
2
56
66
43
59
0407022
Nahid
3
45
56
45
12
0407023
Hanif
4
45
56
23
89
0407020
Shahin
5
100
23
56
66

No comments:

Post a Comment