printing an array
May 23, 2012 at 11:21pm UTC
my program only prints the last value of my array. I can't seem to figure out what I'm doing wrong. all the other code I have looked at seems to function the same way. any assistance would be appreciated
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
#include <iostream>
using namespace std;
void initialize (double doubleList[]);
void printList (double doubleList[]);
int main ()
{
double doubleList [50];
initialize (doubleList);
printList (doubleList);
system("pause" );
return 0;
}
void initialize (double doubleList[])
{
int index=0;
for (index = 0; index < 50; index++)
if (index < 26)
doubleList [index] = index * index;
if (index >= 26)
doubleList [index] = index+index+index;
}
void printList (double doubleList[])
{
int index = 0;
for (index=0; index < 50; index++ );
cout << doubleList[index] << " " ;
}
May 23, 2012 at 11:30pm UTC
Remove the semicolon at the end of line 41.
May 23, 2012 at 11:59pm UTC
Thanks... my bad
Topic archived. No new replies allowed.