1

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.

3
  • 4
    What book are you using in class? while loops are a pretty basic concept. Commented Apr 9, 2011 at 21:16
  • 4
    Post a (brief) example that you don't understand. Commented 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 sense Commented Apr 10, 2011 at 4:05

3 Answers 3

3

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; } 
Sign up to request clarification or add additional context in comments.

2 Comments

Surely eat_french_fry() should decrement the count? :) :P
Sure. Didn't want to confuse things, though. ;)
1
 while (SOME_CONDITION) { /* Block Of Code */ } 

Translates to:

 label: if (SOME_CONDITION) { /* Block Of Code */ goto label; } 

What else is there to know?

Comments

0

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.

1 Comment

Thanks now its making more sense :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.