Explore BrainMass

Looping and Case Statements

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

1. When using Case statements, what would happen if you did not "Break?" Please give an example and explain.

2. Where, in your everyday life, would you use all of the looping techniques,

? Pseudocode for looping structures
? Operators continued
? The while loop
? The do while loop
? The for loop
? break and continue statements
? System calls

Give examples. (Please do not use any computer languages in your examples)

Example: While hair is dirty, Shampoo hair - Apply small amount of shampoo to hair, lather, rinse, and then repeat until clean. (Please be more detailed)

© BrainMass Inc. brainmass.com October 24, 2018, 10:33 pm ad1c9bdddf

Solution Preview

1. If the "break" statement is not used in a case-switch structure, all the options will be gone through and evaluated instead of just the single, relevant one, which will render the program inefficient.

2. Pseudocode for looping structures
Suppose that I have to drive from my house to the post shop, bank, local library, children's crèche, a friends place and my mom's house. I do not exactly know the way (as I will check it on my GPS system when driving), but I have a general idea what way to go to visit all these places and I make a rough mental map in my mind about driving directions. This is an example of a pseudo code.

? ...

Solution Summary

462 words give real life examples of loop behaviour to illustrate the technique in computing.

See Also This Related BrainMass Solution

Repetitive control structures, Techniques of passing arguments

1. Discuss various counter controlled repetitive control structures.

2. The if...else is suitable for simple program but switch...case is a better construct, which is suitable for more complex problems? Do you agree with this or not? Discuss with suitable examples.

3. We can replace any code that uses a for loop with a while loop. Would not it be simpler to get rid of the for loop and use the while for everything? Do you think this would be a good idea? Why or why not?

4. Write a program using equality and assignment operator with their symbol. Which type of error is generated, using them incorrectly? Discuss the results.

5. Write the example that demonstrates different techniques of passing arguments: by value, by reference, and as pointers. Discuss the three methods.

View Full Posting Details