workshop_4.cpp

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> #include <string> #include <vector> // ARRAYS //five elements of type int int my_array[5]; //initialized five elements of type int int my_array_2[5] = {5, 4, 7, 8, 2}; //initialized five elements of type int last two are 0’s int my_array_3[5] = {5, 4, 7}; //universal array initialization int my_array_4[] = {5, 4, 7, 8, 2}; //2-D array with height of 6 and width of 5 int my_array_5[6][5]; // POINTERS //pointer to an int int *my_pointer; void print(std::string *pointer) { std::cout << "Pointer: " << *pointer << std::endl; } // VECTORS std::vector<int> my_Vector; //Some Vector functions std::my_Vector.push_back(60); std::my_Vector[0]; std::my_Vector.size(); std::my_Vector.pop_back(); int main() { // --- Arrays ---- int capacity = 5; std::string input; std::string movies[capacity]; std::cout << "Please enter your 5 favorite movies.\n"; for (int r = 0; r < capacity; r++) { std::cout << r+1 << "? \n"; std::getline(std::cin, input); movies[r] = input;
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern