cooperk50
asked on
What are the logical parts?
What are the logical parts that are necessary to make an iterative control structure useful?
This question doesn't really make any sense. It's like saying, "What are the logical parts that are necessary to make a building useful?". Can you re-phrase it maybe?
ASKER
I guess what I'm trying to say is I need help explaining the logical parts that are necessary to make an iterative control structure useful.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To add to evilrix... For iteration you need not only a predicate but also something that enables it to be finite -- some functionality that leads to the next step. It can be increment or decrement of an integer variable, moving the iterator, whatever.
I personally consider the iteration control structure useful when it nicely reflect our mental picture of solving the problem. I mean, not our mental picture how the procesor should do it. The matematical approach is a good example: "for each element of the..." set, for example.
From that point of view I like the Python generalisation of the for loop:
for element in "iterable":
process the element
Then whatever is iterable, its processing can be prescribed via that simple syntax.
To summarize, the "necessary" or "useful" can be classified from low-level point of view or from high-level abstractions point of view.
I personally consider the iteration control structure useful when it nicely reflect our mental picture of solving the problem. I mean, not our mental picture how the procesor should do it. The matematical approach is a good example: "for each element of the..." set, for example.
From that point of view I like the Python generalisation of the for loop:
for element in "iterable":
process the element
Then whatever is iterable, its processing can be prescribed via that simple syntax.
To summarize, the "necessary" or "useful" can be classified from low-level point of view or from high-level abstractions point of view.
Did you read the tutorial I posted a few times already in your other questions ?
http://www.cplusplus.com/doc/tutorial/control.html
http://www.cplusplus.com/doc/tutorial/control.html
ASKER
Yes
>> Yes
Then you should have already known this ;) That tutorial explains all parts of all loop types in detail :) You might want to refer to it when you have further problems ...
Then you should have already known this ;) That tutorial explains all parts of all loop types in detail :) You might want to refer to it when you have further problems ...