#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
float calculateAverage(int[]);
char Grade(float);
char line[100];
int marks[100];
ifstream input;
ofstream output;
clrscr();
input.open("k:\\input.txt");
output.open("k:\\OUTPUT.txt");
if(!output)
cout<<"Output file error";
if (input)
{
while (!input.eof() )
{
input>>line;
cout << line <<endl;
output<<line;
for(int i=1;i<=5;i++)
{
int num;
input>>num;
marks=num;
}
float avg=calculateAverage(marks);
char grd=Grade(avg);
output<<grd<<endl;
}
input.close();
}
else cout << "Unable to open file";
getch();
return 0;
}
float calculateAverage(int marks[])
{
int tot;
float avg;
for(int i=1;i<=5;i++)
{
tot=tot+marks;
}
avg=tot/5.0;
return avg;
}
char Grade(float avg)
{
char g;
if((avg<=100)&&(avg>=90))
g='A';
else if((avg<=89)&&(avg>=80))
g='B';
else if((avg<=79)&&(avg>=70))
g='C';
else if((avg<=69)&&(avg>=60))
g='D';
else
g='F';
return g;
}
tis is the .txt file content
Johnson 85 83 77 91 76
Aniston 80 90 95 93 48
Cooper 78 81 11 90 73
Gupta 92 83 30 69 87
Blair 23 45 96 38 59
Clark 60 85 45 39 67
Kennedy 77 31 52 74 83
Bronson 93 94 89 77 98
Sunny 79 85 28 93 82
Smith 85 72 49 75 63
i have a prob with tis code...it comes like tis...
1>------ Build started: Project: yahoo grade calculator, Configuration: Debug Win32 ------
1>Compiling...
1>yahoo grade calculator.cpp
1>c:\users\q-mar\desktop\assignment hand in monday\yahoo grade calculator\yahoo grade calculator\yahoo grade calculator.cpp(17) : error C3861: 'clrscr': identifier not found
1>c:\users\q-mar\desktop\assignment hand in monday\yahoo grade calculator\yahoo grade calculator\yahoo grade calculator.cpp(43) : error C3861: 'getch': identifier not found
1>c:\users\q-mar\desktop\assignment hand in monday\yahoo grade calculator\yahoo grade calculator\yahoo grade calculator.cpp(54) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
1>Build log was saved at "file://c:\Users\Q-mar\Desktop\assignment hand in monday\yahoo grade calculator\yahoo grade calculator\Debug\BuildLog.htm"
1>yahoo grade calculator - 2 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
cn anione help me out solve tis error...plz...i m blank and have no idea wat i should do...i m a noob n beginner in C++