cplusplus:repetition_examples
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
cplusplus:repetition_examples [2019/02/11 17:42] – [Sentinel-controlled repetition] mithat | cplusplus:repetition_examples [2019/02/11 17:49] – [Input validation] mithat | ||
---|---|---|---|
Line 87: | Line 87: | ||
int num; | int num; | ||
- | cout << "Enter a number between " << LOWER_BOUND << " and " << UPPER_BOUND << ": "; | + | cout << "Enter a number between " << LOWER_BOUND |
+ | << " and " << UPPER_BOUND << ": "; | ||
cin >> num; | cin >> num; | ||
- | // Pass through loop only if input is valid. | + | // Fall through loop only if input is valid. |
while (num < LOWER_BOUND || num > UPPER_BOUND) | while (num < LOWER_BOUND || num > UPPER_BOUND) | ||
{ | { | ||
- | cout << "Enter a number between " << LOWER_BOUND << " and " << UPPER_BOUND << ": "; | + | cout << "Enter a number between " << LOWER_BOUND |
+ | << " and " << UPPER_BOUND << ": "; | ||
cin >> num; | cin >> num; | ||
} | } |
cplusplus/repetition_examples.txt · Last modified: 2019/02/14 21:28 by mithat