This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
notes:cprog:spring2024:projects:cnv0 [2024/03/06 20:43] – [for() loops] amelvil2 | notes:cprog:spring2024:projects:cnv0 [2024/03/06 20:54] (current) – [do-while loops] amelvil2 | ||
---|---|---|---|
Line 68: | Line 68: | ||
i--; | i--; | ||
} while ( i > 0 ) | } while ( i > 0 ) | ||
+ | </ | ||
+ | |||
+ | An example of a do-while loop being used. This loop will check if the user has inputted the correct password. The loop will continue until number equals 1234: | ||
+ | |||
+ | < | ||
+ | int number; | ||
+ | do { | ||
+ | printf(" | ||
+ | scanf(" | ||
+ | } while (number != 1234); | ||
</ | </ |