Printing an array in lines of 10.
I've tried several ways to do this but I either copy one variable 10 times or they all go on the same line. How do I display an array of 50 with 10 per line?
Here is the code I already have
Code:
#include <iostream>
#include <cmath>
using namespace std;
const int arraySize = 51;
int main()
{
double alphaArray[arraySize];
for (int i=1; i < 51; i++)
{
alphaArray[i]= i; // Store a number in each array element
if( i < 25)
{
cout << sqrt(i) << ' ' <<endl;
}
else
{
cout << i * 3 << endl;
}
}
return 0;
}
any help would be appreciated.