cp_1_lect_31 - Example #define COLMAX 10 #define ROWMAX 5...

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

View Full Document Right Arrow Icon
5/10/10 Example #define COLMAX 10 #define ROWMAX 5 main() { int row,column, y; row = 1; printf(" MULTIPLICATION TABLE \n"); do /*. ..... OUTER LOOP BEGINS. ....... */ { column = 1; do /*. ...... INNER LOOP BEGINS. ...... */ { y = row * column; MULTIPLICATION TABLE 1 2 3 10 2 4 6 20 3 6 9 30 4 8 12 40 5 10 15 50
Background image of page 1

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

View Full DocumentRight Arrow Icon
5/10/10 Jumps in Loops May need to skip a part of loop or to leave the loop when a particular condition occurs For example, when a negative number is input, skip the rest all processing;
Background image of page 2
5/10/10 Jumps in Loops continued… A goto statement can cause program control to end up anywhere in the program. With good programming skills, goto can be avoided . .
Background image of page 3

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

View Full DocumentRight Arrow Icon
5/10/10 for and while as everlasting loops /* A bad loop style */ for ( ; ; ) { /* A better loop style */ for ( ; !condition ; ) { } /* A bad loop style */ while ( x ) { if (condition) break; else } /* A better loop style */ while ( x && !condition) { if ( !condition ) …; }
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

cp_1_lect_31 - Example #define COLMAX 10 #define ROWMAX 5...

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

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