0

Alright. Basically the point of this program is to allow a user to select how many fractions they want printed on the screen. It is supposed to print 3 fractions PER line. If a user requests 4 fractions..it would print 3 and print the 4th fraction by itself on the next line.

The numerator is any number between 1 - 10. Denominator is any number between 1 - 20. Currently...with what I have it gets stuck in an infinite loop and I can't quite put my finger on what is causing it.

On a side note, I'm really rusty with C++. It's been years.

```
#include <iostream>
#include <cstdlib>
using namespace std;
struct Fraction
{
int num; //non-negative number
int den; //non-negative number
};
int main(void)
{
Fraction *intList;
int arraySize;
cout << "How many fractions would you like to display? ";
cin >> arraySize;
cout << endl;
intList = new Fraction[arraySize];
//initializing values of the array
for(int i=0; i<arraySize; i++)
{
intList[i].num = (rand()%10)+1;
intList[i].den = (rand()%20)+1;
}
for(int z=0; z<arraySize; z+3)
{
cout << intList[z].num << "/" << intList[z].den << " ";
if (z+1 > arraySize)
{
break;
}
else if (z+1 < arraySize)
{
cout << intList[z+1].num << "/" << intList[z+1].den << " ";
}
if (z+2 > arraySize)
{
break;
}
else if (z+2 < arraySize)
{
cout << intList[z+2].num << "/" << intList[z+2].den << " " << endl;
}
}
system("PAUSE");
return 0;
}
```

*Edited 7 Years Ago by wyett*: n/a