Programming Technique-1

LAB 4

Text

#include <iostream>
#include<conio.h>
#include <fstream>
using namespace std;

int main()
{
ifstream inFile;
ofstream outFile;
const int SIZE=40;
char name[SIZE];
int score;
int count = 0;
float avrg,total;


inFile.open("inputdata.txt");
outFile.open("mahi.txt");

inFile>>name>>score;
outFile << name << " " << score << " ";
if(score>=50)
outFile<<"pass" << endl;
else
outFile<<"fail" << endl;
total=total+score;

inFile>>name>>score;
outFile << name << " " << score << " ";
if(score>=50)
outFile<<"pass" << endl;
else
outFile<<"fail" << endl;
total=total+score;

inFile>>name>>score;
outFile << name << " " << score << " ";
if(score>=50)
outFile<<"pass" << endl;
else
outFile<<"fail" << endl;
total=total+score;


avrg = (total)/3;
outFile << "Average = " << avrg;

inFile.close();
outFile.close();
getch();
}