Feb 5, 2017 at 4:25am Feb 5, 2017 at 4:25am UTC
Hi I need help in learning how to pass an array without using pointers and this is a homework assignment. I already have the first part of this hw assignment done which is what alpha is i just need to be able to pass the contents of the array alpha[50] to beta[50]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
#include <iostream>
using namespace std;
const int arraySize = 50;
double initializeArray(double alpha[arraySize]);
void printArray();
double copyArray(double alpha[arraySize],double beta[arraySize]);
int main ()
{
const int arraySize = 50;
double alpha[arraySize],beta[arraySize];
for (int i = 0; i < 51; i++)
{
beta[50] = initializeArray(alpha);
}
copyArray(alpha,beta);
return 0;
}
double initializeArray(double alpha[arraySize])
{
for (int i = 0; i < 25; i++)
{
alpha[i] = i * i;
if (i % 10 == 0 && i != 0 && i != 100)
{
cout << endl;
}
cout << alpha[i] << "\t" ;
}
for (int i = 25; i < 50; i++)
{
alpha[i] = i * 3;
if (i % 10 == 0 && i != 0 && i != 100)
{
cout << endl;
}
cout << alpha[arraySize] << "\t" ;
}
for (int i = 0; i < 51; i++)
{
return alpha[i];
}
}
double copyArray(double alpha[arraySize],double beta[arraySize])
{
for (int i = 0;i < 51;i++)
{
cout << beta[i] <<"\t" ;
}
}
Last edited on Feb 5, 2017 at 4:27am Feb 5, 2017 at 4:27am UTC