#pass array to function
8 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
!format
Using namespace std;
Void myArray( ```cpp
int x[5] )
{
for (i = 0; i < 5; i++)
{
cout << x[i] << " "
}
}
int main() {
int myArray[5] = {1, 2, 3, 4, 5};
printArray(myArray);
return 0;
}
!format
Using namespace std;
void myArray(int x[5])
{
for (i = 0; i < 5; i++)
{
cout << x[i] << " "
}
}
int main() {
int myArray[5] = {1, 2, 3, 4, 5};
printArray(myArray);
return 0;
}
When I run this I get 1 2 3 4 5
Last time I thought it has to iterate from 0 to 4 when it reaches 5 it stops looping isn't??
!solved