#include#include//reading/writing to file using namespace std; //uses input.Dat,
ID: 3657247 • Letter: #
Question
#include#include//reading/writing to file using namespace std; //uses input.Dat, //create() IS ONLY FOR TESTING PURPOSES void create(){ int test[]={76,89,150,135,200,76,12,100,150,28,178,189,167,200,175,150,87,99,129,159,176,200,87,35,157,189 }; ofstream dat; dat.open("scores.txt"); if(dat.is_open()){ cout<<"Making test file "; for(int i=0;i<26;i++){ dat<<test[i]<<endl; } dat.close(); } else cout<<" Test file no made "; return; } int main(){ int cnt=0, num,size=0; int *numbers=NULL;//pointer initialize to null int catagories[8]={0}; create(); //USED FOR TESTING PURPOSE ONLY (CREATES SCORES.TXT FILE) ifstream myfile; myfile.open("scores.txt"); if(myfile.is_open()){//only takin in input file open cout<<"File successfully opened. "; while(!myfile.eof()){ //read until end of number // Build the dynamic array myfile >> num; //try reading data if(!myfile.eof()){ numbers = (int *) realloc (numbers,(size+1) * sizeof(int)); numbers[size++] = num; } } myfile.close();//close file //count grades in grade range for(int j=0;j<<" Score Range Number of Students "; for(int i=0;i<8;i++){ cout<<i*25<<"-"; if(i==7) cout<<(i+1)*25; else cout<<(i+1)*25-1; cout<<" "<<catagories[i]<<endl; } }//end if open OK else cout<<"File failed to open";// if file did not open delete[] numbers;//free memory cout<<" Press any key to continue . . ."; cin.get(); return 0; }Explanation / Answer
please paste the code properly in a readable way
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.