Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /*
- COS 132 Activity 1:
- Remember that Arrays are zero indexed. This means that the first element of the array is reffered to as MyArray[0].
- Therefore when declaring an array with n elements, we declare it as MyArray[n-1].
- Done by Matthew Kelly.
- */
- int main()
- {
- // Declaring Variables.
- int Choice;
- int Number;
- int MyArray[4];
- // Getting Values.
- cout << "Enter a number: ";
- cin >> Number;
- cout << "Enter a choice: ";
- cin >> Choice;
- switch(Choice)
- {
- case 1:
- // Case 1:
- for (int i = 0; i < 5; ++i)
- MyArray[i] = -5 + Number;
- break;
- case 2:
- // Case 2:
- for(int i = 0; i < 5; ++i)
- MyArray[i] = i - Number;
- break;
- case 3:
- // Case 3:
- for (int i = 0; i < 5; ++i)
- MyArray[i] = 5 * (7 * (i + 1));
- break;
- }
- // Outputting each element of the array.
- for(int i = 0; i < 5; ++i)
- cout << MyArray[i] << " ";
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement