Lecture 3 - DO Statement Review of C Fundamentals do cfw...

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

View Full Document Right Arrow Icon
1 Review of C++ Fundamentals (Part 2) 2 DO Statement do { cin >> X; // something or other } while (X > 0); 3 Break and Continue • Break gets you out of the loop. Completely out. • Continue skips the rest of the loop and restarts with the next iteration at the beginning. For “for loops” the “after action is still performed before jumping out of the loop. 4 Arrays • One Dimensional Arrays • Multidimensional Arrays • Arrays of Arrays • Strings 5 One-Dimensional Arrays • int ar1[30]; • This defines ar1[0], ar1[1], ..... ar1[29] • Better way of doing it: const int size = 30; // define size typedef int myarray[size]; //def type myarray bunch_of_numbers; 6 Arrays over enumerations enum days {SU, MO,...}; days Day; for (Day = SU; Day<SA; Day = days(Day+1)) cout << array_of_nums[Day] << endl;
Image of page 1

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

View Full Document Right Arrow Icon
7 Initialization and Assignment • Array assignment is illegal!!!!!! • Initialization: arrayType X = {1, 3, 4}; • If you don’t initialize all values, the rest are set to 0. • Arrays in function headers may have open sizes []. • Arrays are never passed by value. 8 CONST Array Parameters int compute_somethg(const int vals[], int N); N stores the valid size which the function might want to know.
Image of page 2
Image of page 3
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