Question

Let's compare the various loop structures. As we did in last week's discussion, give a real...

Let's compare the various loop structures. As we did in last week's discussion, give a real world example of using various loops.

Can you give an example of when you might not be able to use a particular type of loop such as a For loop?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

There are basically three types of looping structures.

  • while
  • do-while
  • for

a while loop keeps executing a certain block of statements until a condition becomes false. Example , traversing a linked list until there are no more nodes to traverse.

do-while loop is used when we have to run a set of statements atleast once. Example, showing a menu of options to a user. We have to show the menu atleast once , the user might quit the very first time though.

for loops are usually preferred for their compactness because they have initialization , condition and updation statements in a single line. You can achieve what a for loop can with a while loop as well. Its just that for loops have better readability.

Add a comment
Know the answer?
Add Answer to:
Let's compare the various loop structures. As we did in last week's discussion, give a real...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You may recall in last week's extra credit, we showed that if you give a PDA...

    You may recall in last week's extra credit, we showed that if you give a PDA 2 stacks instead of 1, it's able to accept the language a^n b^n c^n that no normal PDA could accept. This week, we'll show an even stronger result Show how any Turing machine can be converted to an equivalent 2-stack PDA. (This proves that the set of languages 2-stack PDAs can be built to accept is exactly the set of decidable languages)

  • Reflection Question: Formatting and Customizing Documents ♦ As outlined in this week's reading, give two examples...

    Reflection Question: Formatting and Customizing Documents ♦ As outlined in this week's reading, give two examples of how text alignment is controlled between margins using indents. Explain how these indents are used and when they are appropriate to apply. ♦ Why is it useful to be able to set and use tab stops in Word? Describe when you might use a decimal tab and a tab with a leader?

  • The Real World An Introduction to Sociology 6e This first discussion that involves the subject matter...

    The Real World An Introduction to Sociology 6e This first discussion that involves the subject matter of the textbook in Chapter 1. In order to understand the three major theoretical perspectives in Sociology, it is often helpful to apply them to a real-life topic. For example, if I want to apply the sociological theories we study in Chapter 1 of the Real World to the social issue of environmental problems for this theory discussion. 1. Structural-Functionalist Perspective 2. Conflict Perspective...

  • 5.6 - Discussion: Should Loops be Well-Disciplined, or... ...Should Programmers be able to use “GO TO”...

    5.6 - Discussion: Should Loops be Well-Disciplined, or... ...Should Programmers be able to use “GO TO” statements as they please? Some programming languages require that a loop only have one way in, and one way out; there are no “GO TO” statements. Other languages (like BASIC and FORTRAN) allow for statements to have “labels”, or addresses, that another statement like a GO TO can explicitly transfer control. Discussion: What do you see as the strengths and weaknesses of each of...

  • My company that i did in the last discussion was Target store, please keep this in...

    My company that i did in the last discussion was Target store, please keep this in mind. there is an example below in the last picture. Discussion 2 (part of chapter 3's work) Available on Saturday, September 12, 2020 6:00 AM EDT until Sunday, September 27, 2020 11:59 PM EDT Subscribe We have learned about four types of adjustments: (1) deferred expenses, (2) deferred revenues, (3) accrued revenues, and (4) accrued expenses. Using the same service business that you identified...

  • This week's discussion is an application assignment. I want you to create your own survey. When...

    This week's discussion is an application assignment. I want you to create your own survey. When conducting research, sometimes creating your survey instrument is the most tedious and time-consuming activity. For this week, let's keep things simple and say that you are conducting exploratory research on student perception/satisfaction of college textbooks--essentially, do students like their textbooks, dislike their textbooks, or not have an opinion about their textbooks. There are many questions to ask that may affect textbook perception/satisfaction. The genesis...

  • This week's discussion is an application assignment. I want you to create your own survey. When c...

    This week's discussion is an application assignment. I want you to create your own survey. When conducting research, sometimes creating your survey instrument is the most tedious and time-consuming activity. For this week, let's keep things simple and say that you are conducting exploratory research on student perception/satisfaction of college textbooks--essentially, do students like their textbooks, dislike their textbooks, or not have an opinion about their textbooks. There are many questions to ask that may affect textbook perception/satisfaction. The genesis...

  • Let's make sure we understand the underlying concepts of using job-order costing. Consider the following for...

    Let's make sure we understand the underlying concepts of using job-order costing. Consider the following for this discussion board (you may need to use additional resources outside of the textbook - be sure not to copy and paste responses directly from any source and cite your resources): 1. Compare and contrast job order costing and process costing systems. 2. What kind of company might use process costing? Support your answer. 3. In a process costing system, direct materials are often...

  • Fair Value Measurements As you examined in this week's Discussion, fair value measurements can influence financial...

    Fair Value Measurements As you examined in this week's Discussion, fair value measurements can influence financial reporting. For an accountant, it can also be considered a moving target, especially when values of certain assets, such as financial instruments, are based on a changing market. The pressures associated with reporting according to fair value measurements also pose ethical dilemmas. As you prepare for this Application, consider how ethics impacts accounting practice and how final assenting and dissenting opinions of rule making...

  • In this week's Discussion, it's time to narrow down the top three areas where you plan...

    In this week's Discussion, it's time to narrow down the top three areas where you plan to market your product. If you are including Social Media, that will account for one area. This Discussion will take a little outside research as I want you to include any costs associated with your plan. For example, if you plan on using radio (which may or may not be a good idea for your specific product), research the cost to have a spot...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT