what is this

Pages: 12
Create an array of integers in the main program then call a function that prints out the array (you need to pass the array to the function)


is equal to:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>

using namespace std;
// Function definition.
void printArray(int someArray[], int size){
    for(int i = 0; i < size; i++){
        // Print out the value held by the element corresponding to i.
        cout << someArray[i] << endl; 
   }
}


int main()
{
    int myArray[10] = {0, 1, 2, 4, 5, 6 , 7, 8, 9}; // Remember to assign values to each element.
    printArray(myArray, 10); // Pass the array to the function and the size of the array.

    return 0;
}


So yes it is.
thats my final resolution? so i could just submit that answer?
thats my final resolution? so i could just submit that answer?
and that is why people frown giving full solutions.

Edit the purpose to assignments are for you to try it and learn from it not to copy paste :P

Edit 2 I noticed in your earlier post you are struggling with arrays.

1
2
3
4
int num[1];
num [0]=9;

cout << num[1]+num[0];


When you do int num[1]; you are declaring an array with 1 element so accessing num[1] is out of bounds and unless you really know what you are doing and even then you are probably going to get undefined results. basically you are just outputting 9 + ???

You may want to read these:
http://www.cplusplus.com/doc/tutorial/arrays/
http://www.learncpp.com/ <--chapter 6


Ps. I hate to break it to you but telling us you only have a few hours left doesn't help get answers any faster. That just tells us you procrastinated more than likely or did not ask clear enough questions.
Last edited on
Topic archived. No new replies allowed.
Pages: 12