لو سمحت كنت عايز اقرا درجات الطلاب واسمائهم من ملف ثم اطبع اذا كان ناجح ام راسب
#include <iostream>
#include <fstream>
#include <string.h>
#include <cstdlib>
#include <cstring>
using namespace std;
void main()
{
ifstream infile;
char c;
char names[50];
int grades;
int lines=1;
infile.open("data.txt",ios::in);
fstream outfile;
outfile.open("result.txt",ios::out);
if(!infile)
{
cout<<"Can't Open The File"<<endl;
exit(1);
}
if(!outfile)
{
cout<<"Can't Open The File"<<endl;
exit(1);
}
while(infile.get(c))
{
if(c=='\n') lines++;
}
infile.clear();
infile.seekg(0);
for (int i=0;i<lines;i++)
{
infile>>names;
outfile<<names;
if(infile>>grades)
{
if(grades>=50)
{
outfile<<" Your grade is "<<grades<<" Pass"<<endl;
}
else if(grades<50 && grades >= 0)
{
outfile<<" Your grade is "<<grades<<" Fail"<<endl;
}
else
{
outfile<<" Wrong Grade "<<endl;
}
}
}
infile.close();
outfile.close();
}
