learning C++ in my computer science class in school. Im having a hard time picking up the while Looping concept(event controlled, count controlled, Etc). can any one point me in the right decision or send me some great internet sources that explain it way better than the book we are using in class thanks.
- 4What book are you using in class? while loops are a pretty basic concept.Random832– Random8322011-04-09 21:16:34 +00:00Commented Apr 9, 2011 at 21:16
- 4Post a (brief) example that you don't understand.jonsca– jonsca2011-04-09 21:19:43 +00:00Commented Apr 9, 2011 at 21:19
- We are using Nell Dale and Chip Weem's programming and problem solving with C++ but thanks to all your answers and reading the chapter again its making more senseFrantz Romain– Frantz Romain2011-04-10 04:05:11 +00:00Commented Apr 10, 2011 at 4:05
3 Answers
While's aren't difficult to understand. Think about it in terms of food:
while (french_fry_count > 0) { eat_french_fry(); --french_fry_count; } When i started learning these concepts, i translated it to simple english. For example, in case of while loops, the common english translation could be, do some steps (step 1 , 2 & 3 ) while the "condition" is true. Now the condition can be .. when count of a variable reached to 10, which basically mean you have a while loop based on counting of a variable value. The other scenario where "condition" can change is , 'while you are performing step 1, 2 or 3.. something changed inside while loop which resulted in "condition=false". This is now event based.