Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //----------------------------------
- // Week 4 : Arrays
- //----------------------------------
- // It is now week 4. It has been nearly a month and
- // I have barely covered over the basic syntax of coding. If this was a university
- // course, I believe they would already finish all of this by week 1!
- // (Actually they really do. I took a real course at a university
- // and they quickly and thoroughly explained the differences in two weeks).
- // But hey! I am just a single person learning on my own.
- // I don't want to be hopping on shiny toys, but rather I would take the time to really
- // learn my foundation and seeing it how it all
- // work together.
- // English definition: ordered arrangement, in particular.
- // An array isn't all that complicated.
- // Syntax
- // datatype arrayName[arraysize];
- // The array size is how many elements do you want the array to have.
- // Declaration
- // int ticketNumbers[3];
- // Initization
- // ticket Numbers[3] = {0,3,4,5};
- // Declaring and initization
- // int ticketNumbers[3] = {0,3,4,5};
- // An array is consist of elements.
- // We can access the elements of an array by calling its index.
- // Exercises
- int ticketNumber[3];
- ticketNumber[3] = {0,3,4,5};
- std::cout << ticketNumbers[1];
- // Try running this code.
- // What number do you get when you call the index at 1?
- // Try changing the index to 0, 3, 4, and 2. What numbers do you get?
- // List them below
- // What are the usages of arrays?
- // Say, I got a list of ID numbers.
- // We can store different numbers into each list and access them based on their order.
- // int IDnumber[5] = {25,15,16,13,14}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement