I am fairly new to stackoverflow and coding, so I do not know what to do at this point. As the tile mentions, this code just does not output anything. It only runs, but with no output. I do not know what to do at this point. I am using Visual Studio Code with g++. And yes I have checked that the input file is placed correctly. What could be the problem?
#include <iostream>
#include <fstream>
using namespace std;
const int NR = 10;
const int NC = 5;
int getTotal(int arr[NR][NC]);
float getAverage (int arr[NR][NC]);
int rowTotal (int arr[NR][NC], int numOfRow);
int colTotal (int arr[NR][NC], int numOfCol);
int getHighestInRow (int arr[NR][NC], int numOfRow);
int getLowestInRow (int arr[NR][NC], int numOfRow);
int main()
{
ifstream file("arraysfile.txt");
int arr[NR][NC];
int total = 0;
float avg = 0.0;
int rowTotal = 0;
int colTotal = 0;
int highestInRow = 0;
int lowestInRow = 0;
int numOfRow = 0;
int numOfCol = 0;
for (int r = 0; r < 10; r++)
{
for (int c = 0; c < 5; c++)
{
file >> arr[10][5];
}
}
total = getTotal(arr);
avg = getAverage(arr);
cout <<"What row would you like to process?"<<std::endl;
cin >> numOfRow;
cout <<"What column would you like to process?"<<std::endl;
cin >> numOfCol;
rowTotal = (arr, numOfRow);
colTotal = (arr, numOfCol);
highestInRow = getHighestInRow(arr, numOfRow);
lowestInRow = getLowestInRow(arr, numOfRow);
cout << "Total sum of all number is: "<<total<<std::endl;
cout << "Average of all numbers is: "<< avg <<std::endl;
cout << "Sum of row # "<<numOfRow<< " is: "<<rowTotal<<std::endl;
cout << "Sum of column # "<<numOfCol<< " is: "<<colTotal<<std::endl;
cout << "The highest number in row # "<<numOfRow<< " is: "<<highestInRow<<std::endl;
cout << "The lowest number in row # "<<numOfRow<< " is: "<<lowestInRow<<std::endl;
}
int getTotal(int arr[NR][NC])
{
int total = 0;
for (int i = 0; i < NR; i++)
{
for (int j = 0; i <NC; j++)
{
total+=arr[i][j];
}
}
return total;
}
float getAverage (int arr[NR][NC])
{
float avg = 0.0;
int total = 0;
for (int i = 0; i < NR; i++)
{
for (int j = 0; i <NC; j++)
{
total+=arr[i][j];
}
}
avg = (total/(NR/NC));
return avg;
}
int rowTotal (int arr[NR][NC], int numOfRow)
{
int rowTotal = 0;
for (int i = 0; i < NC; i++)
{
rowTotal += arr[numOfRow-1][i];
}
return rowTotal;
}
int colTotal (int arr[NR][NC], int numOfCol)
{
int colTotal = 0;
for (int i = 0; i < NR; i++)
{
colTotal += arr[i][numOfCol-1];
}
return colTotal;
}
int getHighestInRow (int arr[NR][NC], int numOfRow)
{
int highest = arr[numOfRow][0];
for (int i = 0; i < NC; i++)
{
if (arr[numOfRow][i] > highest)
{
highest = arr[numOfRow][i];
}
}
return highest;
}
int getLowestInRow (int arr[NR][NC], int numOfRow)
{
int lowest = arr[numOfRow][0];
for (int i = 0; i < NC; i++)
{
if (arr[numOfRow][i] < lowest)
{
lowest = arr[numOfRow][i];
}
}
return lowest;
}