Saturday, 11 June 2016

Search Student From Exam Result Sheet Project in C++

Leave a Comment
Instructions:

Below mention code is compiled in Code Blocks , Visual Studio 2015 and TC .Output snap is attached.. If any problem you feel and want explanation feel free to contact.

Code:

/**************************************************|
/*************C++ Programs And Projects************|
***************************************************/
#include<fstream>
#include<iostream>
#include<conio.h>
#include <string.h>
#pragma warning (disable:4996)
using namespace std;
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;
       system("cls");
       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


///////////////////////////////////////////////////////////////////////////
Copy & paste this code in your TC & run, then you will get output.......

If you have any problem please comment below.........*/


Related Articles:

C++ Projects

If You Enjoyed This, Take 5 Seconds To Share It

0 Questions: