On a daily basis, we work with any number of interfaces that use iteration to op
ID: 3604579 • Letter: O
Question
On a daily basis, we work with any number of interfaces that use iteration to operate. For instance, on an alarm clock, pressing the snooze button resets the alarm to go off again in a set amount of time; turning the alarm off is what "breaks" the loop. Discuss at least one real-world interface for which you can explain how iteration is used. Your example can be brief, but should include some discussion regarding initialization (state of the world when the iteration starts), test to continue (what makes the iteration continue) and incrementation (how do we work toward an end to the iteration)?
Explanation / Answer
This is really an intresting question,Facebook would be the best example here.
For example when you try to view your frineds in the friends list , you will be able to see their profie photo,name and profile link and so on.For this happen we need code to iterate over each friend in your list to display corresponding data.
Sample code snippet:
foreach(var $friend in $user->friends) {
show_friend($friend);
}
This will make sure that loop iterates till the end of your friends list and will brek once it reaches the last one in your list.
Thanks for the opportunity.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.