Just started on arrays and am totally lost. Problem: Write a program that reads
ID: 3615452 • Letter: J
Question
Just started on arrays and am totally lost.Problem:
Write a program that reads a file consisting of students' testsscores in the range 0-200. It should then determine the number ofstudents having scores in each of the following ranges: 0-24,25-49, 50-74, 75-99, 100-124, 125-149, 150-174, and 175-200. Outputthe score ranges and the number of students.
Run your program with the following input data:
76 89 150 135 200 76 12 100 150 28 178 189 167 200 175 150 87 99 129I have to use this format:
149 176 200 87 35 157 189
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
void readData(ifstream& inputFile, int list[], int size);
void print(int list[], int size);
int main()
{
return 0;
}
void readData(ifstream& inputFile, int list[], int size)
{
}
void print(int list[], int size)
{
}
--------------------------------------------
I just can't seem to make it work using only two functions. Ifsomeone could please help and explain/show me how to do thisproblem, it would be greatly appreciated. Thank you for yourtime.
Explanation / Answer
please rate - thanks #include #include #include using namespace std; void readData(ifstream& inputFile, int list[], int&size); void print(int list[], int size); int main() {ifstream input; int list[50],size=0; input.open("input.txt"); //open file if(input.fail()) //is it ok? { coutlist[size]; while(inputFile) {size++; inputFile>>list[size]; } } void print(int list[], int size) {int i,j,tot[8]={0}; for(i=0;i=0;j--) if(list[i]>j*25) {tot[j]++; j=-1; } for(i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.