lecture_08-Slides_6_per_page - Iterative constructs allow...

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

View Full Document Right Arrow Icon
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 x0 int x = 0; while (x < 2) { printf(“x=%d\n”,x); x = x + 1; } while vs. do while
Background image of page 1

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

View Full Document Right Arrow Icon
2/5/2014 2 int x = 0; while (x < 2) { printf(“x=%d\n”,x); x = x + 1; } while vs. do while x0 x=0 int x = 0; while (x < 2) { printf(“x=%d\n”,x); x = x + 1; } while vs. do while x1 x=0 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 x=1 int x = 0; while (x < 2) { printf(“x=%d\n”,x); x = x + 1; } while vs. do while x2
Background 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 ]}

Page1 / 7

lecture_08-Slides_6_per_page - Iterative constructs allow...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online