//Header Files #include <fstream> #include <iostream> using namespace std; void
ID: 3610382 • Letter: #
Question
//Header Files
#include <fstream>
#include <iostream>
using namespace std;
void main()
{
//The Start of the main function
//variable declaration. use 8 because its the number of groupst hatthe grades are sorted into
int counter[8],score,i;
//for infile
ifstream infile;
//For loop
for(i=0;i<8;i++);
counter[i]=0;
//opening the file and inputing the score
infile.open("input.txt");
infile >> score;
//-200 indicates end of text file
//reading scores fromf ile
while (score!=-200)
{
i=score;
counter[i]++;
infile >> score;
} // end while
//variables for ranges
int first=0, last=24;
//For loop
//Outputing scores between ranges
for(i=0;i<8;i++)
{
//Displaying the results
cout << "The ScoreBetween" << first<< "-" << last<< "Is: " <<counter[i] << endl;
first=last+1;
last=first+24;
//If Statment
if(i==6)
last++;
} // end of forloop
//closes the infile
infile.close();
//system pause
system("pause");
while (score!=-200)
{
i=score;
counter[i]++; it particularrydosnt liek this part when i runt heprogram.
infile >>score;
}//end while
Explanation / Answer
please rate - thanks you had to divide the number by 25 to get the category, but thenumber 200 was a special case because it went with the lowergrouping. and I put some spacing in you output, there wasalso an extra ; so counters weren't set to 0. for my compiler Ineed int main() and return 0 // Header Files #include #include #include #include using namespace std; int main() { // The Start of the main function // variable declaration. use 8 because its the number of groupsthat the grades are sorted into int counter[8], score,i; // for infile ifstream infile; // For loop for(i=0;i> score; //-200 indicates end of text file //reading scores fromf ile while(score!=-200) { i=score/25; if(i==8) i--; counter[i]++; infile >> score; } // end while //variables for ranges int first=0, last=24; // For loop //Outputing scores between ranges for(i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.