Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- struct Student {
- int kcstID;
- int quiz1;
- int quiz2;
- int quiz3;
- float average;
- };
- int main() {
- // Write Code to open Binary File
- ifstream exam ("student.dat" , ios::in | ios::binary);
- const int n=5 ;
- if(!exam) {
- cout << "Cannot open file" << endl;
- return 1;
- }
- Student stu[n];
- cout << "\n\t\t Kuwait Colleg of Science and Tecnology , Doha Kuwait "<<endl;
- cout <<"---------------------------------------------------------------------------- -";
- for ( int i = 0 ; i < n ; i++){
- exam.read((char *)&stu[i], sizeof(Student));
- if (stu[i].quiz1 <= stu[i].quiz2 && stu[i].quiz1 <= stu[i].quiz3){
- stu[i].quiz1 = 0;
- }
- if (stu[i].quiz2 <= stu[i].quiz1 && stu[i].quiz2 <= stu[i].quiz3){
- stu[i].quiz2 = 0;
- }
- if (stu[i].quiz3 <= stu[i].quiz1 && stu[i].quiz3 <= stu[i].quiz2){
- stu[i].quiz3 = 0;
- }
- cout << "\n" << stu[i].kcstID << "\t" << stu[i].quiz1 << "\t" << stu[i].quiz2 << "\t" << stu[i].quiz3 << "\t" << stu[i].quiz1 + stu[i].quiz2 + stu[i].quiz3;
- }
- exam.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement