Lab: Arrays

Requirements

Modify the supplied program (arrayLab.cpp) to make it work properly.

Program to be modified

/*
    arrayLab.cpp
    Name: 
    CIS 150
    Date: 
    
    CIS 150 Chapter 8 Arrays Lab
*/

/*
    Place your name and section at the top in comments.
    Read the instructions for each section and then implement
    your solution within this program.
*/

#include <iostream>
using namespace std;

int main() {
    // 1. Declare an array of type integer named iNum and initialize
    //    it with the values 2, 4, 6, 8, 10.
    
    // 2. Write a statement to output the third element of array iNum
    //    followed by a newline.
    
    // 3. Write a statement to store the value 12 in the last
    //    element of array iNum.
    
    // 4. Declare an integer variable named index and set that variable
    //    to the value needed to use it as an index to access the second
    //    element of the array iNum.

    // 5. Use the variable "index" as a subscript to display the 
    //    second value of the iNum array.
    
    // 6. Write a "while" loop using index that will output all of the
    //    elements of the array iNum. The values should be separated by
    //    a space and a newline should be output at the end.

    // 7. Write a function that takes three arguments. The first is the
    //    name of an integer array, the second is an integer that specifies
    //    a position in the array, and the third is an integer that will
    //    be stored in the array. This function returns nothing.
    
    // 8. Write the prototype for the function above and place it before main()
    
    // 9. Call the function you wrote and send it the iNum array, 1, and 21 as
    //    the arguments, which should store 21 in the second element of the array.
    
    //10. Write a "for" loop using index that will output all of the elements
    //    of the array iNum. The values should be separated by a space and
    //    a newline should be output at the end.
    
    cout << "Press enter to continue...";
    cin.get();
    return 0;
}

Example run of program

6
4
2 4 6 8 12
2 21 6 8 12
Press enter to continue...

Points (10 points total)