```
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <iomanip>
#include <fstream>
using namespace std;
const int MAX = 51;
const int setArray = 5;
float initialArray[MAX][setArray];
void createRationalNo (int, int);
float RationalInfo (float[][setArray], int);
void printArray (float[][setArray], int);
int main()
{
cout << "No\tP\tQ\tQuo\tRem\tValue\n\n";
srand(time(NULL));
int setPQ = 2;
createRationalNo (MAX, setPQ);
RationalInfo (initialArray, MAX);
printArray (initialArray, MAX);
cout << endl;
system ("pause");
return 0;
}
void createRationalNo (int size, int set)
{
int i;
int j;
ofstream outfile;
outfile.open("infile.txt");
for (i = 0; i <size; i++)
{
for (j = 0; j < set; j++)
{
initialArray[i][j] = (rand () % 99) +1;
outfile << initialArray[i][j] << " ";
}
}
outfile.close();
}
float RationalInfo (float initialArray[][setArray], int size)
{
int quotient, remainder;
float value;
int j = 0;
ifstream infile;
infile.open("infile.txt");
for (int i = 0; i < size; i++)
{
int x, y;
float z;
infile >> x >> y;
initialArray[i][j+2] = x / y;
initialArray[i][j+3] = x % y;
z = x / y;
initialArray[i][j+4] = z;
infile.close();
}
return 1;
}
void printArray (float initialArray[][setArray], int size1)
{
int count = 1;
int j = 0;
int i = 0;
while (size1 > 1)
{
cout<< setiosflags(ios::fixed);
cout<< setiosflags(ios::showpoint);
cout<< setprecision(2);
int p, q, r, s;
p = initialArray[i][j];
q = initialArray[i][j+1];
r = initialArray[i][j+2];
s = initialArray[i][j+3];
cout << count
<< "\t" << p << "\t" << q
<< "\t" << r << "\t" << s
<< "\t" << initialArray[i+4][j] << endl;
j++; count ++; size1--;
}
}
```

Hi guys, I need some help with my assignment.

The program's suppose to generate 50 random numbers, store them in a text file, then use those numbers and calculate their quotient, remainder and value.

Example:

No P Q Quo Rem Value

1 1 15 0 1 0.07

2 9 36 0 9 0.25

3 84 8 10 4 10.50

4 52 70 0 52 0.74

5 24 47 0 24 0.51

6 62 86 0 62 0.72

7 21 25 0 21 0.84

8 70 84 0 70 0.83

9 47 71 0 47 0.66

10 96 6 16 0 16.00

What my code produces now.

No P Q Quo Rem Value

1 31 21 1 10 88.00

2 21 1 10 1 63.00

3 1 10 1 80 1.00

4 10 1 80 48 10.00

5 1 80 48 1 1.00

6 80 48 1 10 68.00

7 48 1 10 1 33.00

8 1 10 1 58 1.00

9 10 1 58 84 10.00

10 1 58 84 1 1.00

11 58 84 1 10 53.00

12 84 1 10 1 53.00

This weird result pops up. Can anyone help me with it?

I'm trying to troubleshoot it now but no results...