Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

int main() { string line; int row_count = -1, column_count = 1,line_number = 0,

ID: 3617006 • Letter: I

Question

int main() {
    string line;
    int row_count = -1, column_count = 1,line_number = 0, i;
    char nextChar;
    ifstream myfile("data.txt");

    if(myfile.is_open()) { //open file and only count the rows andcolumns, so that the array can be declared

        while(!myfile.eof()) {
           getline(myfile, line); //get a line from the file

           //Counts the number of tabs in the first line of the data file
           if (line_number == 0) {
               for (i = 0; i < line.size(); i++)//check every character in thefirst line
               {
                   nextChar = line.at(i); // gets a character
                   if (nextChar == ' ')
                       column_count++;//counts the column in the file
               }
             line_number++; //make sure we only check the column count of thefirst line
           }
           row_count++; //count the rows in the file
        }
        myfile.close();
      // cout<<row_count<<endl;
       //cout<<column_count<<endl;
    }
    else
        cout << "Unable toopen File";

    intarray[row_count][column_count];
    ifstream myfile2("data.txt");


    //Open the file a second time and populate thearray
    if (myfile2.is_open()) {
        int n, sum , rows,cols;

        while(myfile2 >> n) { //read each integer until the end of thefile

           array[rows][cols] = n; //store the integer
          cout<< cols++; //increment column

           if (cols >= column_count) { //when a column is full goto thenext row
             cout<< rows++;
              // cols = 0;
           }
        }

       myfile2.close();
    } else
        cout << "Unable toopen File";

    //printthe array that has been created
    int x, y;
    for (x = 0; x <= row_count; x++) {
        for (y = 0; y <=column_count; y++) {
           cout<<("%d ", array[x][y]);
        }
        cout<<(" ");
    }

    return0;
}

Explanation / Answer

please rate - thanks I made a bunch of small changes. I did not make the input into functions since you already didthe input code #include #include #include #include using namespace std; void largesmallrow(int[][100],int,int,int&,int&); voidlargesmallcol(int[][100],int,int,int&,int&); int main() {     string line;     int row_count = 0, column_count = 1, line_number= 0, i;     char nextChar;     ifstream myfile("data.txt");     int row,col,large,small;     if (myfile.is_open()) { //open file and onlycount the rows and columns, so that the array can be declared              //get a line from the file         while (getline(myfile,line)) {                        //Counts the number of tabs in the first line of the data file            if (line_number == 0) {                for (i = 0; i