Advertisement
bhok

Week 4

Jan 16th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. //----------------------------------
  2. // Week 4 : Arrays
  3. //----------------------------------
  4.  
  5. // It is now week 4. It has been nearly a month and
  6. // I have barely covered over the basic syntax of coding. If this was a university
  7. // course, I believe they would already finish all of this by week 1!
  8. // (Actually they really do. I took a real course at a university
  9. // and they quickly and thoroughly explained the differences in two weeks).
  10. // But hey! I am just a single person learning on my own.
  11. // I don't want to be hopping on shiny toys, but rather I would take the time to really
  12. // learn my foundation and seeing it how it all
  13. // work together.
  14.  
  15. // English definition: ordered arrangement, in particular.
  16. // An array isn't all that complicated.
  17.  
  18. // Syntax
  19. // datatype arrayName[arraysize];
  20. // The array size is how many elements do you want the array to have.
  21.  
  22. // Declaration
  23. // int ticketNumbers[3];
  24. // Initization
  25. // ticket Numbers[3] = {0,3,4,5};
  26. // Declaring and initization
  27. // int ticketNumbers[3] = {0,3,4,5};
  28.  
  29. // An array is consist of elements.
  30. // We can access the elements of an array by calling its index.
  31.  
  32. // Exercises
  33.  
  34. int ticketNumber[3];
  35. ticketNumber[3] = {0,3,4,5};
  36. std::cout << ticketNumbers[1];
  37.  
  38.  
  39. // Try running this code.
  40. // What number do you get when you call the index at 1?
  41. // Try changing the index to 0, 3, 4, and 2. What numbers do you get?
  42. // List them below
  43.  
  44. // What are the usages of arrays?
  45. // Say, I got a list of ID numbers.
  46. // We can store different numbers into each list and access them based on their order.
  47. // int IDnumber[5] = {25,15,16,13,14}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement