Question

when creating computer programs to solve problems, there are three types of repetition that you can...

when creating computer programs to solve problems, there are three types of repetition that you can use. Describe the three types of loop and provide a pseudocode example of each

Homework Answers

Answer #1

The three types of loops are for loop, while loop, do while loop.

For Loop: This is used when a set of statements are to be executed a specific number of times.This is an entry controlled loop meaning looo terminating condition is checked in the beginning of the loop

Structure of for loop:

for( initialisation ; test condition : update statement )

{

}

Psuedo Code:

for( i = 0 ; i < 5 : i++ )

{

Print " i will be printed 5 times "

}

While Loop: While loop is used when the number of iterations is not known before hand because this is an entry controlled loop.

Structure of loop:

While ( condition )

{

}

Psuedo Code:

i= 1

While ( i < 5)

{

Print " i am a while loop "

}

Do While loop: Do while loop is used when a set of statements need to be executed atleast once before checking the loop terminating condition

Loop Structure:

do

{

} while ( condition ) ;

psuedo Code:

i= 0

do

{

Print " i am a do while loop "

} while ( i < 5 );

Know the answer?
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
Similar Questions
When creating a computer program, the developer is trying to solve a problem with the program....
When creating a computer program, the developer is trying to solve a problem with the program. Your task is to explain the final three steps in the problem-solving process. Create a new entry describing these steps.
How do you solve for covariance? Can you provide an example(s) on how to solve the...
How do you solve for covariance? Can you provide an example(s) on how to solve the following three problems: Cov(7X,Y)= Cov(X, 4Y)= Cov(.05X, .2Y)=
How do you solve the following types of problems? No data needed. Just need to know...
How do you solve the following types of problems? No data needed. Just need to know HOW one would solve or define these problems. Compute Net Income and Retained Earnings Calculate total assets and total liabilities from general ledger accounts Characteristics of liabilities and assets Debt and Credit rules and types of accounts affected by each Explain the transactions when given a journal entry Identify recordable transactions Calculate current assets and current liabilities Depreciable assets vs capitalized assets
Computer programs with benign malicious intents are threat to computer and network security. Explain three ways...
Computer programs with benign malicious intents are threat to computer and network security. Explain three ways such undesired programs negatively affect its host or target computers. b) Render in an elaborative manner, some defensive measures that one can take to protect host or target computers from malicious computer programs. a) A notable attack recorded in the computing fraternity in October 2002 was successfully launched against the Internet’s 13 root servers, which act as the Internet’s ultimate authority with respect to...
Pick three types of bacteria that you can use to open up three profitable businesses. Briefly...
Pick three types of bacteria that you can use to open up three profitable businesses. Briefly describe (<2 sentences each type) your theoretical basis for your business
How many diffrent two-digit numbers can you use the digits 4,3,7,1,2,6, and 9 without repetition? For...
How many diffrent two-digit numbers can you use the digits 4,3,7,1,2,6, and 9 without repetition? For example, 77 is not allowed The number of diffrent two-digit number is
Instructions: You are required to use a financial calculator or spreadsheet (Excel) to solve the problems...
Instructions: You are required to use a financial calculator or spreadsheet (Excel) to solve the problems (provided on page 4) related to risk and return characteristics and stock/bond valuation. You are required to show the following three steps for each problem (sample problems and solutions are provided for guidance): (i) Describe and interpret the assumptions related to the problem. (ii) Apply the appropriate mathematical model to solve the problem. (iii) Calculate the correct solution to the problem. A company’s non-callable...
Instructions: You are required to use a financial calculator or spreadsheet (Excel) to solve the problems...
Instructions: You are required to use a financial calculator or spreadsheet (Excel) to solve the problems (provided on page 4) related to risk and return characteristics and stock/bond valuation. You are required to show the following three steps for each problem (sample problems and solutions are provided for guidance): (i) Describe and interpret the assumptions related to the problem. (ii) Apply the appropriate mathematical model to solve the problem. (iii) Calculate the correct solution to the problem. The market return,...
7) provide an example of when you might use each of the following types of charts....
7) provide an example of when you might use each of the following types of charts. For example, you would use a pie chart to show the proportion of children in grades 1 through 6 who receive a reduced price lunch. When you are done, draw the fictitious chart by hand. A) Line B) Bar c) Scatter/Dot
When governments produce public goods, they can simultaneously solve old problems and create new ones’. Do...
When governments produce public goods, they can simultaneously solve old problems and create new ones’. Do you agree or not? Justify your answer.