Question

In: Computer Science

What is the difference between a pretest and posttest Do...loop statement? give an example of each...

  1. What is the difference between a pretest and posttest Do...loop statement? give an example of each loop using pseudocode.
  2. What is infinite loop, how to avoid your program runs with an endless loop? give an example using psuedocode or explanation

Solutions

Expert Solution

What is the difference between a pretest and posttest Do...loop statement? give an example of each loop using pseudocode.
A pretest is something which is checked before entering into the loop and executing loop statements..
like:
while(condition is true) {
        // execute.
}

A posttest is something, which is checked after executing the loop statements.. Hence there is a gurantee that the loop statements will run atleast once.. the posttest basically determines if the loop statements should be executed again or not.

do {
        // execute.
} while(condition is true);
==================


What is infinite loop, how to avoid your program runs with an endless loop? give an example using psuedocode or explanation

=>
An infinite loop is something, whose looptest condition always remains true..

while(true) {
        // Print something.
}

A loop of above kind will keep running infinitely, and will never stop (until your system supports). To Avoid such kind of cases, We should define some end condition or break statements.. like below:

while(true) {
        if(condition) {
                break;
        }
        // Print something.
}
**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.


Related Solutions

Describe the differences between a nonequivalent comparison group design and a one-group pretest-posttest design. For each,...
Describe the differences between a nonequivalent comparison group design and a one-group pretest-posttest design. For each, give an example of a situation in which one might have to use that design rather than a strong experimental design. What is the critical aspect of your example that makes it impossible to use a strong experimental design?
What is the difference between an attribute and a metric? Give an example each of an...
What is the difference between an attribute and a metric? Give an example each of an attribute of a service that is done correctly, incorrectly, or not at all and a metric for it. (Performance analysis modelling class)
What is the difference between an allergy and an autoimmune disease? Give an example of each.
What is the difference between an allergy and an autoimmune disease? Give an example of each.
What is the difference between a valid and an invalid complaint? Give an example of each....
What is the difference between a valid and an invalid complaint? Give an example of each. What is the difference in how these are treated from a customer service standpoint?
What statistical tool should I use in a pretest posttest control group design?
What statistical tool should I use in a pretest posttest control group design?
what is the difference between delayed fertilization and delayed implantation? Give an example of each.
what is the difference between delayed fertilization and delayed implantation? Give an example of each.
What is the difference between symbolic and functional consumer needs? Give an example for each
What is the difference between symbolic and functional consumer needs? Give an example for each
what is difference between industry analysis and market analysis give example of each
what is difference between industry analysis and market analysis give example of each
What is the difference between social responsibility and social entrepreneurship, and give an example of each...
What is the difference between social responsibility and social entrepreneurship, and give an example of each one. -  What does the triple bottom line mean?  Explain the practices that your business can do to be considered a triple bottom line venture.
Explain the difference between active and latent error. Give an example of each. Which do you...
Explain the difference between active and latent error. Give an example of each. Which do you think is the most common in health care? Why? This is for a discussion post. Please provide at a minimum 200 words in your response. If you can't provide 200 words, please don't attempt to provide a response. Thank you very much in advance.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT