What the diffrent bettween while looping, conter-controlled while loop, sentinel-controlled while loop,flag-controlled while loop, do while loop and For loop.
when we use each one of them???
please, explean in detileas.
thanx
:)
What the diffrent bettween while looping, conter-controlled while loop, sentinel-controlled while loop,flag-controlled while loop, do while loop and For loop.
when we use each one of them???
please, explean in detileas.
thanx
:)
Homework? Try reading your textbook.
EDIT: See above.
What the diffrent bettween while looping, conter-controlled while loop, sentinel-controlled while loop,flag-controlled while loop, do while loop and For loop.
when we use each one of them???
A for
loop tends to lend itself to things which need to be done x number of times:
for ( i = 0; i < x; ++i ) { /* ... */ }
A while
loop tends to lend itself to doing things while a condition is true, such as reading lines from a file (while there are lines to read):
while ( getline(file, line) ) { /* ... */ }
A do...while
loop presents itself as a good choice for a loop that must iterate at least once (even if the loop condition is 0, the loop body will execute):
do { /* prompt() */ } while ( respond() );
Other situations present themselves for mix-and-match and programmer preference. YMMV.
"What the diffrent bettween while looping, conter-controlled while loop, sentinel-controlled while loop,flag-controlled while loop, do while loop and For loop. "
Their syntax and spelling:)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.