lecture_08-Slides_6_per_page

# lecture_08-Slides_6_per_page - Iterative constructs allow...

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

2/5/2014 1 Introduction to Programming in C Iterative constructs Problem solving with control structures Style and good programming practices Iterative constructs allow us to repeat a task with less code while do - while for Loop body while (condition) { subtask ; } do { subtask ; } while (condition); while and do while loops repeat the same task as long as a condition is true int x = 0; while (x < 2) { printf(“x=%d\n”,x); x = x + 1; } int x = 0; do { printf(“x=%d\n”,x); x = x + 1; } while (x < 2); while vs. do while int x = 0; while (x < 2) { printf(“x=%d\n”,x); x = x + 1; } while vs. do while x 0 int x = 0; while (x < 2) { printf(“x=%d\n”,x); x = x + 1; } while vs. do while x 0

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

View Full Document
2/5/2014 2 int x = 0; while (x < 2) { printf(“x=%d\n”,x); x = x + 1; } while vs. do while x 0 x=0 int x = 0; while (x < 2) { printf(“x=%d\n”,x); x = x + 1; } while vs. do while x 1 x=0 int x = 0; while (x < 2) { printf(“x=%d\n”,x); x = x + 1; } while vs. do while x 1 x=0 int x = 0; while (x < 2) { printf(“x=%d\n”,x); x = x + 1; } while vs. do while x 1 x=0 x=1 int x = 0; while (x < 2) { printf(“x=%d\n”,x); x = x + 1; } while vs. do
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern