COP 3223C Lecture Notes - Lecture 15: Scanf Format String

53 views3 pages
29 Sep 2016
School
Course
Professor

Document Summary

In our while loop we saw that the minimum # of times that the loop code is run is 0. There are times when you might want to have the code run at least 1 time. For example when requesting data that has to be validated. In such a case we have the choice of using a different kind of loop - the do while loop. Note: there is a ; at the end of the expression do{ statement1; statementn; Example: do{ ask customer to select a drink read drink selected check if selection is valid. Example int choice; do{ printf( select a drink from 1-15\n ); scanf( %d , &choice); Note that although the expression evaluates to false, the do while loop will be executed at least 1 time. So this type of loop is called a post-test loop (the condition is only tested after the statement/s of the loop have been run)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents